Repository navigation
fix: SQLite write-ahead log, and one session per seeded account in e2e - #16
Merged
Merged
Conversation
Two separate causes made the e2e suite fail now and then with 7 local workers. The SQLite client runs every statement synchronously on the server's only thread. In the default rollback-journal mode each write syncs to disk several times, so while the disk was busy the event loop stood still for up to 5 seconds and any assertion waiting on a server action timed out. The database now uses the write-ahead log (one sync per write), and SQLITE_SYNCHRONOUS=NORMAL turns the per-write sync off; the e2e server sets it for its throwaway database. Payload's login reads the user, checks the password and writes the whole session list back, so logins of one account that overlap sign each other out: 6 concurrent admin logins leave 1 valid session. The seeded accounts are shared by parallel tests, which each logged in for themselves. A global setup now logs each seeded account in once, and the sign-in helpers reuse those sessions. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0122PV8TJ7ELGdAX7H2hdrRU
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two e2e specs (notifications, mailing) failed now and then when the suite ran locally with 7 workers. There were two separate causes, and neither was specific to those specs.
1. Synchronous SQLite writes stall the server
The SQLite client runs every statement synchronously on the server's only thread. In SQLite's default rollback-journal mode each write syncs to disk several times, so whenever the disk is busy nothing is answered until the write returns. Measured with an event-loop monitor in the server during a 7-worker run: the loop stood still for up to 5.4 s while the process used about 25% CPU. Any assertion waiting on a server action then hits Playwright's 5 s limit, in whichever test happens to be waiting.
That also explains the notifications report ("unread was 1 after Mark all as read"): after unfollowing Studio news a new member has exactly one unread notification, so the page had simply not refreshed yet. No notification from a parallel test was involved.
Change: the database uses the write-ahead log (
walinsqliteAdapter), which syncs once per write, with the same durability as before.SQLITE_SYNCHRONOUS=NORMALturns the per-write sync off (safe from corruption; a power cut can lose the last writes). The e2e server sets it, because its database is thrown away.To start over locally, delete
kiln.db*now (the database pluskiln.db-walandkiln.db-shm); README and.env.examplesay so.2. Parallel logins of one account sign each other out
Payload's login reads the user, checks the password and writes the whole session list back. Logins of one account that overlap therefore lose sessions: 6 concurrent logins of the seeded admin leave 1 valid session (6 of 6 when done one after the other). The seeded accounts are shared by tests in different workers, each of which logged in itself, so a test could find itself signed out halfway ("Run the studio digest now" button missing, flag API returning no docs).
Change: a Playwright global setup logs each seeded account in once, in sequence, and
signIn,signInToAdminandadminApiintests/helpers/e2e.tsreuse those sessions. One test still goes through the login form (signInWithForm, site spec).Numbers (full suite,
--workers=7, same machine, other jobs running on it)playwright test notifications mailing --repeat-each=30 --workers=7with this PR: the two reported tests pass 30 of 30, as do four others. "a member sees the bell count…" fails under--repeat-each(21 of 30) because it marks one of the seeded member's notifications as read each time and repeats run in parallel on the same account; it cannot be repeated on one database and passes in every normal run.No timeout or retry was changed.
🤖 Generated with Claude Code
https://claude.ai/code/session_0122PV8TJ7ELGdAX7H2hdrRU