Read model: a failed replay waits before it retries, and the count is what the projection kept (mcl-mail#28) #29
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ceres/28-replay-gate-followups"
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?
Four follow-ups from the review of PR 26 (
3d296ace), all four taken in one pass (mcl-mail#28).1. No backoff between failed replays.
replay_failed/2started a new 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 opposite of what the replay's own wait is for. The pause now starts at 100 ms and doubles per failed attempt up to 5 s; the gate stays off across every attempt, and the first report that reaches the end of the log puts the count back to 0.2.
events_appliedcounted events read. It addedlength(Events)per page, most of which belong to other projections. The count is now whatproject/4kept: the pre-filter is gone, soproject/4's ownok/skipis the answer and nothing in front of it decides.3. The tests that the mutants walked through. Tests first, and each one red before the change that makes it green:
a_replay_failed_from_another_process_does_not_empty_the_table_test— the{replay_failed, Driver, Reason}pid match;a_stranger_exit_does_not_empty_the_table_test— the{'EXIT', Driver, Reason}pid match;a_dead_driver_refills_the_table_before_it_answers_test— a driver killed mid-page: both tables dropped, a new driver started, reads refused until it reports, and the index dropped too (a stale index would skip the re-projected deposit);a_failed_replay_waits_before_it_tries_again_test— no start in the first moments, and a start count over 2.4 s that only a growing pause keeps at or under 8;mailboxes_read_model_replay_tests— the paging loop driven to its end with the store stood in for atevoq_event_store:read_all_global/3(mcl-mail#27's test-side store, one call deep): 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, both pages' letters land, and the count is the kept events of both pages and not the events read.4. The lost-live-mark race is written down where it lives, in
replay_failed/2: the drop empties a table the live projection writes into, so a mark applied just before the wipe comes back only if the new scan reads its event again; where the store's read index lags behind an event that arrived during the failure, the gate can open without it. Narrow, heals at the next restart — not fixed here, and said so on the issue.Proof
rebar3 eunit: All 154 tests passed (32 in the two read-model modules).finally; all nine killed, each by the test named for it (a compile failure does not count): the two 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 lint(MCL_LINT=1) andrebar3 dialyzer: clean.Local toolchain: Erlang/OTP 28.4.3, rebar3 3.28.0, the toolchain
lint.ymlpins.Refs #28, #26.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.