Repository navigation
store: apply a new database's migrations in one transaction - #61
Merged
Merged
Conversation
A new database applied each of its 37 migrations in a transaction of its own, and every commit flushes the rollback journal and the database to disk: 156 fsyncs before store.Open returned. On a busy Windows CI runner that took over thirty seconds, so a freshly started daemon could miss the 30s the CLI e2e harness gives it. CI failed with "daemon never became ready" and empty output; a goroutine dump of the daemon at the deadline shows it still in store.Open -> migrate -> tx.Commit -> FlushFileBuffers, and its log says it started 1.5s after the test gave up. Starts of 5 to 20 seconds, all spent before the address was published, were common on the same runners. Pending migrations now go in one transaction: one commit, 8 fsyncs for a new database (counted with strace), none for one already up to date. A failed step now leaves the schema as it was instead of half upgraded. TestOpeningANewDatabaseCommitsOnce counts commits with the driver's commit hook: 38 before this change, 1 after. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@claude is attempting to deploy a commit to the sivadaboi's projects Team on Vercel. A member of the Team first needs to authorize it. |
This was referenced Oct 15, 2026
Closed
Open
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.
The cause of "daemon never became ready" on Windows CI (seen on #51, CI #319:
TestFreshRestore_SnapshotModeReportsWhatItImported).Cause: a new database applied each of its 37 migrations in a transaction of its own. Every commit flushes the journal and the database to disk, which made 156 fsyncs before
store.Openreturned. On a busy Windows runner that took over 30 s, past the CLI harness's readiness wait.store.Open(median 8.0 s, max 18.8 s).store.Open → migrate → FlushFileBuffers.Fix: all pending migrations go in one transaction: 8 fsyncs for a new database, none for one that's up to date. A failed step now leaves the schema as it was instead of half-upgraded.
Tests (
internal/store/migrate_test.go, using the driver's commit hook):TestOpeningANewDatabaseCommitsOnce: 38 commits before the change, 1 after;TestOpeningAnUpToDateDatabaseDoesNotCommit;TestAFailedMigrationAppliesNothing.After the fix: 0 "never ready" in about 52,000 runs (
store.Openmedian 3.6 s, max 7.7 s).Notes:
internal/store/db.go. Whichever is merged second needs a small rebase: keepopenDB, add Database: WAL, batched clears of deletion records, and giving free space back #53's WAL pragmas to its DSN, and keepcompactOnOpen.🤖 Generated with Claude Code