A failing event's retry sleeps inside the handler and holds up every later event of that handler (head-of-line stall, ~3 s per event) #2

Open
opened 2026-11-25 14:44:24 +00:00 by jupiter · 0 comments
Member

Purpose (bug): one failing event never holds up the events after it for the same handler, so a projection keeps up in production while a single write retries.

Class. evoq_event_handler runs a retry inside the handler process: execute_error_action({retry, DelayMs}, …) calls timer:sleep(DelayMs) and then handles the same event again (evoq_event_handler.erl:350 in 1.30.8). The default policy (evoq_error_handler) is 5 tries, exponential_jitter from 100 ms, so one failing event takes about 3 s or more before it is dead-lettered. The router's courier for that handler calls it with gen_server:call(…, infinity). Every later event for that handler waits in the courier's mailbox for the whole retry run. Other handlers are not held up (one courier each, since the courier change), but that projection's read model stalls: about 3 s per failing event, more when several fail in a row.

Instance. macula-io/macula-realm#26 (repro: issues/26#issuecomment-4692). ProjectRealm.RealmMemberAdmittedV1ToRealmMembers returns {error, _} on a foreign-key miss, which engages the default retry.

  • In the realm's tests, admissions whose realm row was already gone stalled every later admission by 3.5 s per failing event: 581 ms → 4142 ms for one event, a 10 s timeout at four. On a slower runner this compounded: 153 retry lines in one run, and 8/8 desk tests red.
  • The tests' own cause is fixed in the realm (a test now waits for its projections before its sandbox goes). This issue is the production side: a realm whose member projection hits a transient error delays every admission after it by the same amount.

Not proposed here: the shape of the fix. One option is a retry that does not block later events, a send_after to the handler itself, but that changes the per-handler order a projection may rely on. Another is a per-handler cap on the stall. The owner of evoq decides.

Purpose (bug): one failing event never holds up the events after it for the same handler, so a projection keeps up in production while a single write retries. **Class.** `evoq_event_handler` runs a retry inside the handler process: `execute_error_action({retry, DelayMs}, …)` calls `timer:sleep(DelayMs)` and then handles the same event again (`evoq_event_handler.erl:350` in 1.30.8). The default policy (`evoq_error_handler`) is 5 tries, `exponential_jitter` from 100 ms, so one failing event takes about 3 s or more before it is dead-lettered. The router's courier for that handler calls it with `gen_server:call(…, infinity)`. Every later event for that handler waits in the courier's mailbox for the whole retry run. Other handlers are not held up (one courier each, since the courier change), but that projection's read model stalls: about 3 s per failing event, more when several fail in a row. **Instance.** macula-io/macula-realm#26 (repro: issues/26#issuecomment-4692). `ProjectRealm.RealmMemberAdmittedV1ToRealmMembers` returns `{error, _}` on a foreign-key miss, which engages the default retry. - In the realm's tests, admissions whose realm row was already gone stalled every later admission by 3.5 s per failing event: 581 ms → 4142 ms for one event, a 10 s timeout at four. On a slower runner this compounded: 153 retry lines in one run, and 8/8 desk tests red. - The tests' own cause is fixed in the realm (a test now waits for its projections before its sandbox goes). This issue is the production side: a realm whose member projection hits a transient error delays every admission after it by the same amount. Not proposed here: the shape of the fix. One option is a retry that does not block later events, a `send_after` to the handler itself, but that changes the per-handler order a projection may rely on. Another is a per-handler cap on the stall. The owner of evoq decides.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
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/evoq#2
No description provided.