Fix durable inbox to mark envelopes handled atomically with ancillary stores#2394
Merged
jeremydmiller merged 1 commit intomainfrom Mar 31, 2026
Merged
Fix durable inbox to mark envelopes handled atomically with ancillary stores#2394jeremydmiller merged 1 commit intomainfrom
jeremydmiller merged 1 commit intomainfrom
Conversation
… stores When a handler targets an ancillary MartenStore, the incoming envelope was persisted in the main store's inbox but the handler's transaction committed against the ancillary store. The envelope status update was either skipped or targeted the wrong schema, leaving envelopes stuck as Incoming. Changes: - IChain.AncillaryStoreType property tracks which ancillary store a handler chain targets (set by MartenStoreAttribute.Modify) - MessageStoreCollection memoizes message-type-to-ancillary-store mapping at startup for fast lookup - DurableReceiver sets envelope.Store before StoreIncomingAsync so DelegatingMessageInbox routes to the correct store - FlushOutgoingMessagesOnCommit resolves the correct incoming table name for same-database ancillary stores instead of skipping the mark-as-handled update Fixes #2382 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2382
When a handler targets an ancillary
[MartenStore], incoming envelopes were persisted in the main store's inbox but the handler's transaction committed against the ancillary store. TheFlushOutgoingMessagesOnCommitlistener either skipped the mark-as-handled update (same database, different schema) or couldn't reach the correct table (different database), leaving envelopes stuck asIncoming.Changes
IChain.csAncillaryStoreTypeproperty for handler chains to declare their target storeChain.csMartenStoreAttribute.cschain.AncillaryStoreTypeduringModify()MessageStoreCollection.csWolverineRuntime.HostService.csDurableReceiver.csenvelope.StorebeforeStoreIncomingAsyncfor ancillary store routingFlushOutgoingMessagesOnCommit.csHow it works
[MartenStore]are scanned and amessageTypeName → IMessageStoremapping is builtDurableReceiverreceives an envelope, it checks this mapping and setsenvelope.Storeto the ancillary storeDelegatingMessageInboxroutesStoreIncomingAsyncto the correct store based onenvelope.StoreFlushOutgoingMessagesOnCommitupdates the correct incoming table within the handler's Marten transactionFor same-database setups (different schemas), the mark-as-handled SQL targets the main store's incoming table within the ancillary store's Marten session transaction, achieving atomicity.
For different-database setups, the envelope is persisted directly in the ancillary store's inbox, so both the handler's side effects and the envelope status update are in the same database transaction.
Test plan
🤖 Generated with Claude Code