Skip to content

Fix inbox marker conflicts committing duplicate work inside ambient transactions#291

Merged
Vulthil merged 1 commit into
mainfrom
fix/inbox-ambient-conflict
Jul 4, 2026
Merged

Fix inbox marker conflicts committing duplicate work inside ambient transactions#291
Vulthil merged 1 commit into
mainfrom
fix/inbox-ambient-conflict

Conversation

@Vulthil

@Vulthil Vulthil commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

When the relational inbox store runs inside a transaction it doesn't own (e.g. wrapped by another transactional consume filter), a concurrent duplicate delivery that lost the race on the idempotency marker insert was silently swallowed and reported as "skipped" — but since the store can't roll back a transaction it doesn't own, the transaction's actual owner would go on to commit that delivery's business writes anyway. Net effect: a duplicate delivery's side effects got committed while being reported as deduplicated.

The fix rethrows the conflict instead of catching it. The transaction owner then rolls back (discarding the losing delivery's writes), the transport redelivers, and the existing pre-check deduplicates it on the next attempt. The already-correct own-transaction path (used when the store opens its own transaction) is unchanged.

Also fixes a smaller issue: a custom idempotency key selector returning "" was treated differently from returning null, bypassing the documented fallback to the message id and landing in the reject/missing-key path instead.

Includes docs on recommended consume-filter registration order and tests covering both the fixed and already-correct code paths.

  • No public API changes.

Test plan

  • dotnet build — full solution, 0 errors
  • Vulthil.Messaging.Inbox.Tests (net10.0) — 9/9 passed, including a new test proving the empty-string key selector now falls back to the message id (fails on unfixed main)
  • Vulthil.Messaging.Inbox.Relational.Tests (net10.0) — 8/8 passed, including a new test proving the ambient-transaction conflict now propagates instead of letting duplicate work commit (fails on unfixed main) and a concurrency test pinning the already-correct own-transaction path

Backport to v1.0: recommended — internal-only correctness fix for a defect present since 1.0.0.

@Vulthil Vulthil added the backport v1.0 Backport this PR to the v1.0 servicing branch label Jul 4, 2026
@claude

claude Bot commented Jul 4, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@Vulthil
Vulthil merged commit bc22461 into main Jul 4, 2026
7 checks passed
@Vulthil

Vulthil commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

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

Labels

backport v1.0 Backport this PR to the v1.0 servicing branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant