Description
What happens
Since 0.1.0 the server seeds userdata/statev2.sqlite once from userdata/state.sqlite when it starts, and from then on takes up any statev2.sqlite it finds as it is. initializeV2Database returns as soon as the destination exists (apps/server/src/persistence/initializeV2Database.ts). The server never writes state.sqlite again.
An in-app Update from a release before 0.1.0 runs the 0.1.0 server as a trial, and that trial creates statev2.sqlite (with -wal/-shm) while it starts. If the trial fails, the launcher restores only the database the running server named in its update request and returns to the previous version (apps/server/src/serviceLauncher.ts, backupDatabaseOnce/restoreDatabaseBackup on pending.dbPath). For a pre-0.1.0 server that is state.sqlite, so the statev2.sqlite the trial created stays.
The previous server keeps writing state.sqlite. The next Update to 0.1.0 takes up the stale statev2.sqlite. Threads and messages written between the two attempts are then missing in V2; they remain only in state.sqlite, which V2 never reads again.
A trial killed during the import also leaves its snapshot directory userdata/.v2-import-* behind, as large as the V1 database (the scoped temporary directory is not removed on SIGKILL).
Expected
A rolled-back trial leaves no statev2.sqlite that did not exist before it, so the next 0.1.0 start seeds afresh from the current state.sqlite.
The launcher that runs a pre-0.1.0 → 0.1.0 trial is the one of the runtime its unit names, usually older than 0.1.0. A fix only in the launcher therefore does not cover this transition. Possible ways:
- The 0.1.0 server records which
state.sqliteit seeded from, for example size, modification time or SQLite's data version, and seeds again whenstate.sqlitechanged since. - The seed is published under its final name only once the trial reports
prepared.
Context
Lazurio's hosted Environments handle the same case for their own installs: a failed install or pin raise that returns to an older server removes the copy before that server starts again. The in-app Update path is the launcher's and the server's. Found while adapting the hosted Environment tooling to 0.1.0 (#70). Checked at v0.1.0-lazurio.1 (a867ae81) and v0.0.45-lazurio.9.
Activity