Skip to content

Make ReadModelDomainEventHandler idempotent for MerchantFeeSettledEvent duplicate inserts #1872

Description

@StuartFerguson

Background\n\nTransactionProcessor#1864 shows a UniqueConstraintException while handling MerchantFeeSettledEvent in ReadModelDomainEventHandler. The observed failure is a unique constraint violation coming from the SQL read-model path.\n\nRelevant code:\n- TransactionProcessor.BusinessLogic/EventHandling/ReadModelDomainEventHandler.cs\n- TransactionProcessor.Repository/ITransactionProcessorReadModelRepository.cs\n\n## Problem\n\nThe event handling path appears to be inserting a record that already exists, or otherwise re-processing a domain event without an idempotent guard. That turns a data consistency condition into a failed event-handling run.\n\n## Scope\n\n- Review the MerchantFeeSettledEvent / related read-model insert path for duplicate handling.\n- Make the handler or repository idempotent where the event is a replay or duplicate.\n- Add regression coverage for the duplicate/unique-constraint case.\n\n## Acceptance criteria\n\n- Duplicate processing of the merchant-fee-settled read-model path does not throw a unique-constraint exception.\n- The handler logs or returns a clear duplicate/replay outcome instead of failing the whole event-processing path.\n- A regression test covers the duplicate insert case.\n\n## Traceability\n\n- Originating issue: TransactionProcessor#1864

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions