An append is re-sent only when it never reached a worker (#2) #3

Closed
saturnus wants to merge 0 commits from saturnus/2-no-blind-append-retry into main
Member

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,4 and append_if_no_tag_matches/4 are retried only on no_workers or worker_down (noproc), the two errors that prove nothing was delivered.
  • Every other error, {error, timeout} included, goes back to the caller unchanged. For an append it now means "outcome unknown", and the append docs say so.
  • Every other call keeps is_retriable_error/1.
  • New API: reckon_gater_retry:with_retry/4 takes the retry predicate, and is_undelivered_error/1 is the predicate for appends. The retry_config record is unchanged.

Proof

  • reckon_gater_append_once_tests:
    • A stand-in worker that answers after the 5 s timeout and stores every append it gets. Both appends are stored once, and the caller hears {error, timeout}. On main they were sent twice, ending in retries_exhausted.
    • A read is still retried.
    • The undelivered rule is tested on its own.
  • Mutants, each red:
    • M1 timeout on the allow-list.
    • M2 worker_down off it.
    • M3 an unknown error falls back to is_retriable_error.
    • M4 append_events off the append match.
    • M5 append_if_no_tag_matches off the append match.
    • M6 reads take the append rule.
  • Local (OTP 28.4.3): rebar3 compile, xref, lint, eunit (351 pass), ct (8 pass), proper, and scripts/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_version and never a duplicate.

Refs reckon-db-org/reckon-gater#2

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,4` and `append_if_no_tag_matches/4` are retried only on `no_workers` or `worker_down` (`noproc`), the two errors that prove nothing was delivered. - Every other error, `{error, timeout}` included, goes back to the caller unchanged. For an append it now means "outcome unknown", and the append docs say so. - Every other call keeps `is_retriable_error/1`. - New API: `reckon_gater_retry:with_retry/4` takes the retry predicate, and `is_undelivered_error/1` is the predicate for appends. The `retry_config` record is unchanged. **Proof** - `reckon_gater_append_once_tests`: - A stand-in worker that answers after the 5 s timeout and stores every append it gets. Both appends are stored once, and the caller hears `{error, timeout}`. On main they were sent twice, ending in `retries_exhausted`. - A read is still retried. - The undelivered rule is tested on its own. - Mutants, each red: - M1 `timeout` on the allow-list. - M2 `worker_down` off it. - M3 an unknown error falls back to `is_retriable_error`. - M4 `append_events` off the append match. - M5 `append_if_no_tag_matches` off the append match. - M6 reads take the append rule. - Local (OTP 28.4.3): `rebar3 compile`, `xref`, `lint`, `eunit` (351 pass), `ct` (8 pass), `proper`, and `scripts/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_version` and 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#2
Merge remote-tracking branch 'origin/main' into saturnus/2-no-blind-append-retry
All checks were successful
docs / doc snippets (erlang) (pull_request) Successful in 8s
lint-and-test / compile + xref + lint + eunit + ct + proper + dialyzer (OTP 28.4.3) (pull_request) Successful in 1m11s
docs / doc snippets (erlang) (push) Successful in 8s
lint-and-test / compile + xref + lint + eunit + ct + proper + dialyzer (OTP 28.4.3) (push) Successful in 1m4s
582d75302c
Member

Landed by fast-forward: main is 582d75302c (from cc8ffd9e). This repository does not allow the manually-merged style, so the PR is closed by hand.

Landed by fast-forward: main is 582d75302ceed0afdf408da6e4ec457bf3658522 (from cc8ffd9e). This repository does not allow the manually-merged style, so the PR is closed by hand.
terra closed this pull request 2026-12-02 11:26:07 +00:00
All checks were successful
docs / doc snippets (erlang) (pull_request) Successful in 8s
lint-and-test / compile + xref + lint + eunit + ct + proper + dialyzer (OTP 28.4.3) (pull_request) Successful in 1m11s
docs / doc snippets (erlang) (push) Successful in 8s
lint-and-test / compile + xref + lint + eunit + ct + proper + dialyzer (OTP 28.4.3) (push) Successful in 1m4s

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
reckon-db-org/reckon-gater!3
No description provided.