An append is re-sent only when it never reached a worker (#2) #3
Loading…
Reference in a new issue
No description provided.
Delete branch "saturnus/2-no-blind-append-retry"
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 (bug): a gateway append that times out is never sent again, so a slow store cannot write the same event twice (reckon-db-org/reckon-gater#2).
What changes
append_events/3,4andappend_if_no_tag_matches/4are retried only onno_workersorworker_down(noproc), the two errors that prove nothing was delivered.{error, timeout}included, goes back to the caller unchanged. For an append it now means "outcome unknown", and the append docs say so.is_retriable_error/1.reckon_gater_retry:with_retry/4takes the retry predicate, andis_undelivered_error/1is the predicate for appends. Theretry_configrecord is unchanged.Proof
reckon_gater_append_once_tests:{error, timeout}. On main they were sent twice, ending inretries_exhausted.timeouton the allow-list.worker_downoff it.is_retriable_error.append_eventsoff the append match.append_if_no_tag_matchesoff the append match.rebar3 compile,xref,lint,eunit(351 pass),ct(8 pass),proper, andscripts/check_ratchet.sh(58 findings, all in the baseline).Callers checked: reckon-evoq passes the error through. evoq appends with the aggregate's exact version, so its own later write gets
wrong_expected_versionand never a duplicate.Refs reckon-db-org/reckon-gater#2
A gen_server:call timeout does not cancel the request, and reckon-db's gateway worker appends inline, so a timed-out append still lands. Gater treated {error, timeout} as transient and sent it again: the events were stored twice. That happened for one append slower than 5 s, and for one queued behind a slow append in the same worker. append_events/3,4 and append_if_no_tag_matches/4 now retry only no_workers and worker_down (noproc), which prove nothing was delivered. Every other error, timeout included, goes back to the caller unchanged, meaning outcome unknown. Every other call keeps is_retriable_error/1. reckon_gater_retry:with_retry/4 takes the retry predicate, and is_undelivered_error/1 is the one for appends. Tests: a stand-in worker that answers after the timeout stores each append once, and the caller hears {error, timeout}. A read is still retried. The rule is tested on its own. Six mutants were killed. Refs reckon-db-org/reckon-gater#2Landed by fast-forward: main is
582d75302c(fromcc8ffd9e). This repository does not allow the manually-merged style, so the PR is closed by hand.Pull request closed