Skip to content

fix(transactions): release locks when cancel precedes prepare - #10743

Merged
ReubenBond merged 3 commits into
dotnet:mainfrom
ReubenBond:rb-fix-transaction-recovery-stall
Aug 21, 2026
Merged

ReubenBond merged 3 commits into
dotnet:mainfrom
ReubenBond:rb-fix-transaction-recovery-stall

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 21, 2026 •

Copy link
Copy Markdown
Member

Problem

A transaction manager can abort while participant prepare messages are still in flight. The cancel fan-out can arrive first, and the participant previously treated a missing commit-queue entry as already complete while retaining its pre-prepare lock. A late prepare then persisted an orphaned remote commit, blocking later transactions until the 60-second recovery ping and allowing repeated recovery probes to extend the stall.

Solution

Release and service the participant lock when a cancel arrives before the prepare has entered the commit queue. The late prepare then observes a broken lock and completes through the abort path without creating durable pending state. Add focused coverage for the cancel-before-prepare ordering.

Rationale

Transaction IDs are unique and lock rollback is idempotent, so the same path remains safe for duplicate or already-completed cancels while closing the ordering gap that produced the recovery cascade.

Closes #10714

Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings August 21, 2026 08:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an ordering gap in the Orleans transactions participant path where a cancel can arrive before a prepare has been enqueued, previously leaving a pre-prepare lock held and allowing late prepares to persist orphaned remote-commit state that could stall subsequent transactions.

Changes:

  • Release the participant pre-prepare lock when NotifyOfCancel observes no commit-queue entry (cancel-before-prepare ordering).
  • Add a focused unit test asserting that a cancel before prepare results in a broken lock state for the transaction.
Show a summary per file
File Description
test/Transactions/Orleans.Transactions.Tests/TransactionRecoveryLatencyTests.cs Adds a regression test for cancel-before-prepare breaking the participant lock.
src/Orleans.Transactions/State/TransactionQueue.cs Updates cancel handling to rollback the RW lock when the commit-queue entry is missing (cancel overtakes prepare).

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/Orleans.Transactions/State/TransactionQueue.cs
Copilot AI review requested due to automatic review settings August 21, 2026 09:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings August 21, 2026 14:01
@ReubenBond
ReubenBond force-pushed the rb-fix-transaction-recovery-stall branch from 9500e77 to b72251c Compare August 21, 2026 14:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings August 21, 2026 14:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@github-actions github-actions Bot locked and limited conversation to collaborators Sep 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: transaction recovery stalls after graceful silo shutdown

2 participants