Repository navigation
feat(store): never lose the database on a schema upgrade - #41
Merged
Merged
Conversation
Opening the database now protects it before changing it: - copy it to axel.db.v<N>.bak (VACUUM INTO) before migrating from v<N>, keeping the newest two; a failed copy stops the upgrade - refuse a newer database untouched, with a message that says to install the newer build, not to delete the database, and where the pre-upgrade copy is - record a fingerprint of each migration's SQL and refuse, untouched, a database whose migration N came from another branch (SchemaDiverged) - apply each migration in its own IMMEDIATE transaction, re-reading the version under the lock, so concurrent opens run each step once - rename a -wal/-shm left behind by a deleted database instead of letting the new database adopt it
The rex-native build migrated the owner's database to v12 (model_requests, inspected_threads, model_requests.throttled), and main refused it. Copy both migrations verbatim so main opens that database, nothing has to be dropped, and the numbering and fingerprints match when rex-native merges. Only the tables come over; the inspector proxy stays on its branch.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
TL;DR
A branch build (rex-native, schema v12) upgraded the shared
~/.axel/axel.db;main(v10) then refused it, the database got deleted to "fix" it, and every thread in flight was lost. It was recovered from processes that still held it open.Store::opennow copies a database aside before upgrading it, refuses newer or other-branch databases untouched with a message that says not to delete them, fingerprints migrations, runs each one under anIMMEDIATElock, and won't adopt a deleted database's-wal/-shm.Also adopts rex-native's migrations 11 and 12 verbatim (tables only) so
mainopens the recovered v12 database, plus ADR 0011 and RFD 0004 (linked devices, from #40). Upgrades now cost oneVACUUM INTOcopy; the newest two are kept.Agent Trajectory
axel doctorworked, butaxel.dbhad been recreated at 16:49 with every migration stamped at the same second.lsofshowed 14 axel processes still holding the deleted 301 MB file and its never-checkpointed 13 MB WAL, and sharing the old-shmwith the new empty database, which caused the errors.fcopyfile), checked it (integrity_checkok, 15,643 events, 75 threads), and restored it. The installed v10 binary couldn't open it: rex-native had migrated it to v12.VACUUM INTOrefuses a non-empty file. Temp names are now unique per attempt.cargo test -p axel-store: 61 passed. Two tests elsewhere (acphost,configremote) fail locally onmainas well: the 1Password commit signer errors inside their owngit commit.