Commit Graph
2 Commits
Author SHA1 Message Date
Neil 345ffb56d2 perf(sqlite): refresh the legacy profile copy hourly and cap the profile WAL file (#40136)
* perf(sqlite): refresh the legacy profile copy hourly and recover crashed row caches

- The legacy whole-document refresh rewrote every changed split domain each 5 minutes
  (~4-8 MB per cycle, ~200 MB/hour of WAL plus checkpoint on an active profile). Writer
  start and graceful close already bring it current, so refresh at most hourly in between.
- Cap the profile-state WAL at 8 MB; without journal_size_limit it stayed at the size of
  the largest transaction ever written.
- Row caches: a read-only startup read cannot roll back a hot journal (or recover a WAL
  without -shm), so retry once on a writable connection instead of disabling the store
  on every launch.
- Row caches: drop the saved baseline when a commit throws, since COMMIT may report an
  error after the rows landed and our own commit does not move data_version.

* test(sqlite): accept Windows exit status for the crashed-writer fixture; document recovery cost

* docs(sqlite): state the crash-recovery cost without overstating its bound

* fix(sqlite): rebuild a row cache a crash left needing recovery instead of replaying it on main

* revert(sqlite): keep crash-recovery failures non-destructive; drop the rebuild fallback
2026-11-08 21:42:55 -08:00
Neil d101312bee refactor(sqlite): share one row cache across the SQLite-backed caches (#40028)
The last-status, GitHub cache, notification dismissal and model catalog stores each grew their
own legacy-file import, read-only startup read, changed-row writer and retry backoff. They now
share src/main/sqlite/row-cache/ (KeyedJsonRowCache with load/write, the legacy JSON source,
one failure classifier and backoff); each store keeps only its cadence and fencing policy.

Edge cases now behave the same in every store:
- a corrupt or rejected older-build file keeps the stored rows (it no longer wipes them);
- an older-build file that exists but cannot be read is never treated as absent;
- the import receipt is the file's content hash, without its mtime, so a copied leftover is
  still recognised as imported;
- while the rows or that file cannot be read, the store saves nothing that session and never
  deletes a file it did not load (dismissals keep retrying, as before);
- files are user-only and hardened everywhere.

The last-status and GitHub caches move to the shared row layout, so each rebuilds empty once.
2026-11-08 16:37:17 -08:00