Fix OutboxJoin schema initialization and InMemoryLease concurrency issues in fanout tests - #99
Conversation
Co-authored-by: SamuelMcAravey <11021165+SamuelMcAravey@users.noreply.github.com>
a6e4473
into
codex/2025-12-19-add-integration-tests-for-fanoutcoordinator
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ 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".
| if (!resultingLease.IsExpired) | ||
| { | ||
| // Another thread holds a non-expired lease. | ||
| newLease.DisposeAsync().AsTask().Wait(); | ||
| return Task.FromResult<ISystemLease?>(null); |
There was a problem hiding this comment.
Avoid clearing active lease when acquisition is blocked
When a non-expired lease already exists, AddOrUpdate returns it and we immediately dispose the freshly created newLease (lines 310-313). DisposeAsync always invokes RemoveLease, so this path removes the currently held lease from the dictionary even though we return null, letting a subsequent caller acquire a second lease while the original holder is still active. Any concurrent acquisition attempt against an active lease can therefore break exclusivity and allow multiple coordinators to run simultaneously.
Useful? React with 👍 / 👎.
FanoutCoordinatorIntegrationTests failed with "Invalid object name 'dbo.OutboxJoin'" and had concurrency issues in the test lease implementation.
Changes
EnsureOutboxJoinSchemaAsynccall to create OutboxJoin/OutboxJoinMember tablesAddOrUpdatepatternInterlockedoperations for increment/read💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.