Read-model replay gate follow-ups: no backoff, a lost live mark, and the mutants the tests do not kill #28
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Purpose (durability): the four weaknesses the review found in the readiness gate are written down in the repository, so a follow-up worker can take them up in one pass and none of them is lost with a closed review.
From the review of PR 26 (
3d296ace, PASS), which says none of these is required for that change: they are taken up together, or dropped together with a line here.No backoff between failed replays.
replay_failed/2(apps/project_mailboxes/src/mailboxes_read_model.erl:228-233) empties both tables and starts a new driver at once. A store that is down therefore gets a fresh driver as fast as each attempt can fail, and every attempt reads the log from position 0 again. A short, growing pause between attempts — the shapemcl_mail_store's own wait loop uses — would stop a booting store being hammered while it opens, which is exactly the window the wait exists for.A narrow race where a live mark is lost after a failed replay. The live projection writes into the tables whether or not the gate is open (the
deposit,carriedandflagclauses ofhandle_call/3), and a failed replay empties both tables. A mark applied live just before that wipe comes back only if the new scan reads its event again; where the store's read index has not yet caught up with an event that arrived during the failure, the scan can reach the end of the log without it, and the gate opens without that mark. Narrow, in the reviewer's words, and it heals only at the next restart. Worth knowing about before anyone relies on areplay_failedrecovery being lossless.The tests do not kill the pid-match mutants everywhere.
a_report_from_another_process_does_not_open_reads_testcovers the{replayed, ...}clause (mailboxes_read_model.erl:183) only: a build that believed any reporter in{replay_failed, ...}(:186), or that dropped the driver comparison in the{'EXIT', ...}clause (:203), still passes the suite. Nothing covers the trap-exit refill either — a driver killed mid-page, with both tables emptied, a new driver started, and reads still refused while it fills — nor the paging loop itself (paged/5andshort_page/6inmailboxes_read_model_replay.erl). The paging case is what mcl-mail#27 needs a test-side store for.events_appliedcounts events read, not applied.mailboxes_read_model_replay.erl:96and:98addlength(Events)whether or notproject/4did anything with them, and most events in the log belong to other projections. The number in themailboxes_read_model_replayedandmailboxes_read_model_caught_uplog lines is therefore a scan count. Either say so in the key or count the events the projection kept.Done when: each of the four is either fixed with the test that pins it, or dropped with a line here saying why.
Propose no check: none of these earns a CI gate. Refs #26, macula-ci-images#19
All four are taken up, in PR 29. Each of the four is either fixed with the test that pins it, or dropped with a line here saying why — this is the "line here" for the one that is not fixed.
1. No backoff between failed replays — fixed.
replay_failed/2started a driver inside the same call, so a store that was down got a fresh driver as fast as each attempt could fail, each reading the log from position 0. The pause now starts at 100 ms and doubles per failed attempt up to 5 s (RETRY_BASE_MS/RETRY_CAP_MS), the gate stays off across every attempt, and the first report that reaches the end of the log puts the count back to 0. The mutation measured it: the old shape produced 800 driver starts in 50 ms. Pinned bya_failed_replay_waits_before_it_tries_again_test: no start in the first moments after the failure, and a start count over 2.4 s that only a growing pause keeps at or under 8.2. A live mark lost after a failed replay — not fixed; written down where it lives, in
replay_failed/2's own documentation, and here. The drop empties a table the live projection writes into, so a mark applied live just before the wipe comes back only if the new scan reads its event again; where the store's read index has not caught up with an event that arrived during the failure, the scan can reach the end of the log without it and the gate opens without that mark. The reason it is not fixed here: closing it needs a record of every live write since the last successful scan, held for as long as the store stays down — unbounded memory for a race that heals at the next restart, which reads the log once more when the index has caught up. Narrow, as the review said.3. The pid-match mutants — pinned.
a_report_from_another_process_does_not_open_reads_testcovered only{replayed, ...}; both report clauses and the exit now have their own case:a_replay_failed_from_another_process_does_not_empty_the_table_test— areplay_failedfrom a process that is not the owner's driver leaves the letter and the open gate alone;a_stranger_exit_does_not_empty_the_table_test— a process that links to the owner and dies is not a driver dying mid-page;a_dead_driver_refills_the_table_before_it_answers_test— a driver killed mid-page costs both tables, a new driver starts, and reads stay refused until it reports; the new driver re-projects the same letter, so a stale index would skip that write and the letter would be missing — the test proves the index went with the table.The paging loop is pinned too, and it did not need to wait for #27's test-side store.
mailboxes_read_model_replay_testsstands the store in for at its one call,evoq_event_store:read_all_global/3, and drives the realrun/1: a full page does not end the log, the next read starts at exactly the batch, a short page ends it with no further read, every letter from both pages lands, and a log shorter than one page is one read. That is the same seam #27 needs, one call deep.4.
events_appliedcounted events read — fixed. The count is now whatproject/4kept. The list of interesting types no longer sits in front of the projection step:project/4's ownok/skipis the answer, so an event of another projection is theskipit already was and nothing else decides. Pinned by the two-page case, whose page 0 carries two events of another projection and whose short page carries a third: the count must be the kept events (one batch) and not the events read (the batch plus three).Proof
finally, each judged only when the recompile happened and the log names the test that caught it — all nine killed: both pid matches, the refill, the index wipe, a fixed pause, a full page ending the log, the offset not advancing, the count taken from what was read, and a skipped event counted as applied.rebar3 eunit: 154 tests pass;rebar3 lint(MCL_LINT=1) andrebar3 dialyzerclean.Refs #28 (PR 29), #26.
State at park (Supervisor cut the crew to 6, Ceres parked): branch
ceres/28-replay-gate-followupsatb8af6b7, PR 29 open, CI green on that exact tip — run 111 (c4-model, c4-model-1) and run 112 (check, The tested lock arrives whole). HANDOFF sent to Neptunus. Worktree/home/rl/work/worktrees/mcl-mail-28-replay-gate-followupsand the branch stay as they are.