fix(sqlite): concurrent migrate retries

This commit is contained in:
2026-10-26 01:40:40 +01:00
parent 6ae3f54a36
commit 0908b7046a
3 changed files with 77 additions and 7 deletions

View File

@@ -79,7 +79,9 @@ backends dead-letter after the same number of attempts.
and updates `duplicate_window` (1 h) and the consumer's `max_deliver`/`ack_wait` in place, with a
warning in the log. Both are mutable on a live stream/consumer, so no recreate is needed;
immutable consumer fields (name, filter, deliver policy) are never touched.
- Starting server and worker at the same moment against a database that still needs migration `0101`
can make one fail with `duplicate column name`; start the server first, or restart the loser.
- Server and worker both migrate at startup (docker compose starts them together). `sqlite::migrate`
retries with a bounded backoff (100 ms to 1 s, 5 retries), so the loser of a migration race
re-reads `_sqlx_migrations`, skips what the winner applied and succeeds; only a persistent error
is returned.
- Handler authors must keep new handlers idempotent; the ledger narrows duplicates but cannot
remove the crash-after-effect case.