Phase 9, part 6: background work shared safely between copies of the app

internal/jobs keeps named locks as leases in the database (schema 31:
locks, instances), taken with one conditional UPDATE on SQLite or Postgres,
renewed while the work runs and lapsing if its copy stops. Each background
loop's turn, sending an email, audits, discovery runs and imports run
under a lock; OAuth sign-ins under way are kept in the database. Copies
check in, and work marked running is recovered at start only when no
other copy is alive. Settings -> About lists the copies and work under
way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 07:56:47 -07:00
co-authored by Claude Opus 5.5
parent ba6114f367
commit c6c4c40600
18 changed files with 873 additions and 150 deletions
+4
View File
@@ -805,3 +805,7 @@ Throughout, also notice:
Postgres password, it says which and why.
- [ ] After the update to schema 30, Settings → Backups shows the "before
schema 30" backup, and `~/.local/share/supermarket/files` exists, empty.
- [ ] Settings → About → Running lists one copy, "(this one)", seen just
now. While an audit runs, `audit:<site>` shows under *Under way*.
- [ ] Connecting a social account or Search Console still works (sign-ins
under way are now kept in the database).