Repository navigation
Remove racy BackgroundWorker cancellation assertion - #136427
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: jkotas <[email protected]>
|
Tagging subscribers to this area: @dotnet/area-system-componentmodel |
|
@copilot Could you check other BackgroundWorkerTests for race conditions? We also see this intermittent failure: |
There was a problem hiding this comment.
🟢 Approval recommended
The focused deletion removes an invalid concurrent-state check while preserving verification that the worker observes cancellation.
No open issues 🎉
What changed in this PR
This test-only change addresses the intermittent BackgroundWorkerTests.TestCancelAsync failure reported in #133328 without changing production behavior.
Changes:
- Removes the racy main-thread
IsBusy/CancellationPendingcheck and its polling loop. - Retains worker-side cancellation validation and the main-thread signal wait.
Validation was limited to code inspection; no builds or tests were run.
| File | Description |
|---|---|
src/libraries/System.ComponentModel.EventBasedAsync/tests/BackgroundWorkerTests.cs |
Removes an unreliable cancellation assertion while preserving worker-side verification. |
Review effort: Balanced
Co-authored-by: jkotas <[email protected]>
I checked the other tests. |
@copilot This can make the test run slower, but it should not prevent completion. ThreadPool is designed to deal with a pressure like this by injecting more threads. The description of the problem does not look valid. Can you try harder? |
You're right—I overstated the conclusion. With the default ThreadPool, blocking at this barrier should trigger worker injection; it is not an inherent deadlock. The reported 30-second wait only tells us |
I inspected the linked result. It is |
|
@copilot Lets revert the unjustified fix then |
Co-authored-by: jkotas <[email protected]>
|
/backport to release/10.0 Note This comment was posted with GitHub Copilot assistance. |
|
/backport to release/11.0 Note This comment was posted with GitHub Copilot assistance. |
|
Started backporting to |
|
Started backporting to |
…138103) Backport of #136427 to release/10.0 /cc @lewing @Copilot ## Customer Impact - [ ] Customer reported - [ ] Found internally [Select one or both of the boxes. Describe how this issue impacts customers, citing the expected and actual behaviors and scope of the issue. If customer-reported, provide the issue number.] ## Regression - [ ] Yes - [ ] No [If yes, specify when the regression was introduced. Provide the PR or commit if known.] ## Testing [How was the fix verified? How was the issue missed previously? What tests were added?] ## Risk [High/Medium/Low. Justify the indication by mentioning how risks were measured and addressed.] Co-authored-by: Copilot <[email protected]> Co-authored-by: jkotas <[email protected]>
…138102) Backport of #136427 to release/11.0 /cc @lewing @Copilot ## Customer Impact - [ ] Customer reported - [ ] Found internally [Select one or both of the boxes. Describe how this issue impacts customers, citing the expected and actual behaviors and scope of the issue. If customer-reported, provide the issue number.] ## Regression - [ ] Yes - [ ] No [If yes, specify when the regression was introduced. Provide the PR or commit if known.] ## Testing [How was the fix verified? How was the issue missed previously? What tests were added?] ## Risk [High/Medium/Low. Justify the indication by mentioning how risks were measured and addressed.] Co-authored-by: Copilot <[email protected]> Co-authored-by: jkotas <[email protected]>
TestCancelAsynccould fail when it readIsBusyandCancellationPendingduring worker completion, even though cancellation had been observed.