Skip to content

Fix parallel bundle cancellation hang#5572

Open
mikaelweave wants to merge 1 commit into
mainfrom
mikaelweave/fix-bundle-parallel-cancellation
Open

Fix parallel bundle cancellation hang#5572
mikaelweave wants to merge 1 commit into
mainfrom
mikaelweave/fix-bundle-parallel-cancellation

Conversation

@mikaelweave
Copy link
Copy Markdown
Contributor

Description

Batch/transaction bundle parallel operations could hang until the max bundle execution timeout when a parallel worker observed cancellation because the worker only logged OperationCanceledException and did not stop the shared operation. This PR treats the first cancelled parallel worker as terminal for that bundle operation: it marks bundle statistics cancelled, cancels/releases the bundle orchestrator operation, cancels the linked request token so sibling workers observing RequestAborted stop promptly, and rethrows so Task.WhenAll propagates cancellation.

Adds focused regression coverage for a parallel batch where one operation throws OperationCanceledException while a sibling request waits on RequestAborted.

Related issues

Addresses ADO 192125.

Testing

  • dotnet test .\src\Microsoft.Health.Fhir.Api.UnitTests\Microsoft.Health.Fhir.R4.Api.UnitTests.csproj --filter "FullyQualifiedName~GivenABundleRequest_WhenParallelOperationIsCanceled_ThenParallelProcessingCompletesPromptly" --no-restore --verbosity minimal
  • Result: exit 0; Test summary: total: 2594, failed: 0, succeeded: 2594, skipped: 0

FHIR Team Checklist

  • Update the title of the PR to be succinct and less than 65 characters
  • Add a milestone to the PR for the sprint that it is merged (i.e. add S47)
  • Tag the PR with the type of update: Bug, Build, Dependencies, Enhancement, New-Feature or Documentation
  • Tag the PR with Open source, Azure API for FHIR (CosmosDB or common code) or Azure Healthcare APIs (SQL or common code) to specify where this change is intended to be released.
  • Tag the PR with Schema Version unchanged. No SQL scripts or schema changes are included.
  • ADR: N/A. This is a scoped runtime cancellation handling fix and does not change system design assumptions.
  • CI is green before merge Build Status
  • Review squash-merge requirements

Semver Change (docs)

Patch

Cancel the shared bundle operation and linked request token when a parallel bundle worker observes cancellation, then rethrow so parallel processing stops promptly instead of waiting for the bundle timeout.

Add a focused regression test for a cancelled parallel batch operation with a sibling request waiting on RequestAborted.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mikaelweave mikaelweave requested a review from a team as a code owner May 15, 2026 16:10
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.38%. Comparing base (0c27653) to head (f60187f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5572      +/-   ##
==========================================
+ Coverage   77.29%   77.38%   +0.08%     
==========================================
  Files         993      993              
  Lines       36418    36431      +13     
  Branches     5518     5520       +2     
==========================================
+ Hits        28151    28191      +40     
+ Misses       6907     6879      -28     
- Partials     1360     1361       +1     

see 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants