mirror of
https://github.com/zeronsh/comet.git
synced 2026-11-16 18:57:19 +00:00
engine: no snapshot deltas survive a clean stop or a version change
An older engine ignores snapshot_deltas. Rejoin backfill recovers chats whose rows the room stores, but not relay (generation 3) chats or local-only data. So nothing may be left in that table when the version can change. - Before any restart into another version (restart_service: updates, a newer install, the update a channel switch brings), the engine runs DocHost::prepare_for_version_change through a new zeron_update::set_before_restart hook: the store refuses deltas from then on (every save is whole), every open chat is saved whole, and the WAL is checkpointed. A stop cut short after that (launchd's SIGKILL after its timeout) still leaves a store every version reads. - Clean stops already compact (flush_all on shutdown and Cloud sleep). Now a test proves it. Tests: - a_clean_stop_leaves_zero_snapshot_deltas: flush_all leaves zero deltas, reloads equal memory, and after prepare_for_version_change further edits save whole. - dying_between_export_and_commit_keeps_the_last_commit: a child aborts after export and before the write, in the first whole save, in deltas, and in the compacting save (ops 1, 2, 37, 513, 514, 515). The reopened store holds exactly ops 1..at-1 with cursor at-1. - deltas_stay_whole_while_the_cursor_advances_concurrently: a streaming thread, the persister's worker and a forcing thread race (281k ops, 3,287 deltas). Every reload holds ops 1..k with no gap or repeat and k >= cursor; the final reload equals memory. - a_delta_save_retires_a_failed_publication_only_when_it_commits (relay chats): a failed delta write keeps the replay obligation and the old cursor; a committed one clears both in its transaction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>
This commit is contained in:
parent
29ad352469
commit
c004d547c7
5 changed files with 291 additions and 0 deletions
Loading…
Add table
Add a link
Reference in a new issue