Skip to content

Persist MySQL outbox backoff without poisoning broker outages - #676

Merged
thomhurst merged 1 commit into
mainfrom
issue-668-mysql-retry
Nov 13, 2026
Merged

thomhurst merged 1 commit into
mainfrom
issue-668-mysql-retry

Conversation

@thomhurst

@thomhurst thomhurst commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

MySQL direct, maintenance and ordered outbox dispatch now retain failed native sends with durable exponential backoff (1 second to 5 minutes). Broker outages no longer dead-letter unordered rows or park ordered keys at the poison limit. Preparation failures and explicit store failure calls retain their existing poison handling.

Closes #668

Part of #646.

Native and existing features: reuse native client send retries, existing MySQL fenced mutations, deliver_at eligibility and ordered head barriers. Source checked at Azure.Messaging.ServiceBus 7.21.0 (AmqpSender.RunOperation), Dekaf 1.27.0 (Kafka-specific OutboxRelayService in-memory backoff), and MySqlConnector 3.0.0 (native command execution and transactions). None persists eligibility for Relayer's multi-transport MySQL rows. D70 records ownership; no in-process send loop, parallel broker scheduling or new schema is introduced.

All native send exceptions remain eligible indefinitely, including permanent rejections: ITransport batch failures have no portable per-row permanent classification. Every claimed row in a failed batch receives backoff. Ordered heads block their lane until eligible. Diagnostic attempts saturate at 30 and still count toward the preparation/explicit failure poison budget; operators repairing a persistent rejection may need to reset attempts and deliver_at. The MySQL reference and option XML comments document these contracts. Also restored missing D68/D69 links in the decision index.

Per-message cost: one stack bool assignment on ordered dispatch; unchanged successful SQL/awaits/allocations, 0 B. Backoff SQL only runs on failures; no benchmark required.

Validation: 132 focused MySQL tests passed across net10.0/net11.0 (DispatchBackoffTests, MaintenanceTests, OrderedDispatchTests, shared ordered/direct contracts and store tests). Real MySQL 8.4 tests cover 12 failures beyond max=1 on direct notifications, maintenance and ordered dispatch, worker replacement, deadlines, saturation, stale/expired/replayed fences, rollback, poison telemetry and successful recovery. Existing explicit poison tests still pass. npm ci and npm run build passed (Node 26); git diff --check passed.

Validation evidence: /Users/tom/git/Relayer-evidence/pr-676/3e8f638088a7dd62f88296abe20cf3a9fba8e18a/ (logs, reports, regression/fixture source, binaries and verified SHA256SUMS; retained outside worktrees).

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 31b1b56f-2e70-4e98-9de5-2314489fa5b0
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@thomhurst

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T12:12:30.200858Z 3e8f638 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

Review of #676: durable backoff for MySQL send failures

I found no blocking issues. I read the diff and the surrounding code in pr-head. I did not run the tests.

Correctness

  • MySqlRetrySql.Update computes deliver_at from the pre-increment attempts and then sets attempts = LEAST(attempts, 29) + 1. That relies on MySQL's left-to-right single-table UPDATE assignment order, and the comment and D70 both say so. The delays are 1, 2, 4 ... 256 and then 300 seconds. The cap of 30 prevents overflow, and the 2147483647 test covers it.
  • The retry SQL reuses the existing fenced predicate (claim_token plus an unexpired claim). In the ordered lane it runs inside the lane transaction, so a stale or replaced claim returns false and the existing "claim expired" exception path still applies. The DispatchBackoffTests stale-claim and rollback tests exercise this.
  • In MySqlOrderedDispatcher, sending is set only after Prepare succeeds, so preparation failures keep the poison path and native send failures never park a row. A retained head carries a future deliver_at, which the head-read and claim queries already honour, so it blocks its lane and order is preserved.
  • Per-message cost is as the PR states: one bool on the success path, and extra SQL only on failure.

Design

  • The change follows AGENTS.md. It reuses the native client's send retries and the existing deliver_at and fenced-mutation mechanics, adds no schema or scheduler, and records the decision as D70 with the native sources checked. It also restores the missing D68 and D69 index links.
  • Retrying every native send exception indefinitely, including permanent rejections, is a deliberate trade-off. It is documented in D70, in the option XML comments and in the MySQL reference. The cost is that a permanently rejected head blocks its lane until an operator intervenes.

Minor, non-blocking

  • The DispatchFailed log message in MySqlOrderedDispatcher still says rows remain available "after attempt exhaustion, dead-letter management". That is now only true for preparation failures. Consider rewording it so operators are not misled during a broker outage.
  • Consider a warning or a metric when a row's saturated diagnostic attempts reach 30. A permanently rejected row would otherwise sit retrying every 5 minutes with no poison signal beyond the last_error column.

Tests and docs

  • DispatchBackoffTests runs against real MySQL for direct, maintenance and ordered dispatch. It covers 12 failures beyond MaxDispatchAttempts = 1, bounded delays, recovery with fresh worker instances, fencing, rollback and saturation. The existing tests were adjusted to match the new semantics.
  • The website reference and docs/decisions.md are updated in the same PR.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 3e8f638088

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@thomhurst

Copy link
Copy Markdown
Owner Author

Disposition of Claude review #676 (comment) on 3e8f638:

  • Log wording: non-blocking wording suggestion. The shared message covers both preparation failures (which retain poison handling) and send failures (which retry); the documented behavior and exception identify the failure. Declined a wording-only push under the review policy, which permits small optional follow-ups alongside blocking fixes only.
  • Saturation warning/metric: non-blocking observability enhancement. Each failed ordered send already emits DispatchFailed at Error level, and the persisted last_error and deliver_at expose the retained row. An additional saturation signal is optional and introduces no correctness fix; declined for this PR.

Both required reviewers approve this head, and there are no inline threads. Reverified all archived SHA-256 entries successfully at /Users/tom/git/Relayer-evidence/pr-676/3e8f638088a7dd62f88296abe20cf3a9fba8e18a/ (verification log: /Users/tom/git/Relayer-evidence/pr-676/archive-verify.log). No code changed, so validation was not rerun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MySQL outbox dispatch must retain retryable failures with durable backoff

1 participant