-
Notifications
You must be signed in to change notification settings - Fork 149
Fix race condition in IpcTests #8013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (8013) and master. ✅ No regressions detected - check the details below Full Metrics ComparisonFakeDbCommand
HttpMessageHandler
Comparison explanationExecution-time benchmarks measure the whole time it takes to execute a program, and are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are highlighted in **red**. The following thresholds were used for comparing the execution times:
Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard. Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph). Duration chartsFakeDbCommand (.NET Framework 4.8)gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8013) - mean (69ms) : 67, 70
master - mean (69ms) : 67, 71
section Bailout
This PR (8013) - mean (72ms) : 71, 74
master - mean (72ms) : 72, 73
section CallTarget+Inlining+NGEN
This PR (8013) - mean (1,010ms) : 965, 1054
master - mean (1,020ms) : 938, 1101
FakeDbCommand (.NET Core 3.1)gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8013) - mean (106ms) : 103, 108
master - mean (106ms) : 103, 109
section Bailout
This PR (8013) - mean (107ms) : 105, 108
master - mean (107ms) : 106, 109
section CallTarget+Inlining+NGEN
This PR (8013) - mean (737ms) : 677, 797
master - mean (745ms) : 690, 799
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8013) - mean (94ms) : 91, 96
master - mean (94ms) : 92, 96
section Bailout
This PR (8013) - mean (94ms) : 94, 95
master - mean (95ms) : 94, 95
section CallTarget+Inlining+NGEN
This PR (8013) - mean (709ms) : 669, 749
master - mean (709ms) : 663, 755
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8013) - mean (92ms) : 89, 95
master - mean (92ms) : 90, 95
section Bailout
This PR (8013) - mean (93ms) : 92, 94
master - mean (93ms) : 92, 94
section CallTarget+Inlining+NGEN
This PR (8013) - mean (630ms) : 615, 646
master - mean (634ms) : 620, 647
HttpMessageHandler (.NET Framework 4.8)gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8013) - mean (199ms) : 188, 210
master - mean (193ms) : 189, 198
section Bailout
This PR (8013) - mean (202ms) : 195, 209
master - mean (197ms) : 194, 200
section CallTarget+Inlining+NGEN
This PR (8013) - mean (1,125ms) : 1057, 1194
master - mean (1,122ms) : 1053, 1191
HttpMessageHandler (.NET Core 3.1)gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8013) - mean (280ms) : 274, 286
master - mean (277ms) : 271, 282
section Bailout
This PR (8013) - mean (280ms) : 273, 288
master - mean (278ms) : 271, 285
section CallTarget+Inlining+NGEN
This PR (8013) - mean (927ms) : 870, 985
master - mean (920ms) : 873, 967
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8013) - mean (273ms) : 266, 281
master - mean (271ms) : 265, 277
section Bailout
This PR (8013) - mean (274ms) : 269, 279
master - mean (270ms) : 267, 273
section CallTarget+Inlining+NGEN
This PR (8013) - mean (935ms) : 896, 974
master - mean (930ms) : 899, 962
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8013) - mean (272ms) : 263, 280
master - mean (269ms) : 264, 275
section Bailout
This PR (8013) - mean (274ms) : 265, 283
master - mean (270ms) : 265, 276
section CallTarget+Inlining+NGEN
This PR (8013) - mean (835ms) : 804, 867
master - mean (822ms) : 803, 841
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Summary of changes
Fixed race condition in IpcClientTest that caused intermittent test failures where finalValue.ClientValue was 19 instead of 20.
Reason for change
The test was failing intermittently in CI with:
Expected finalValue.ClientValue to be 20, but found 19 (difference of -1).Root cause: Race condition where TaskCompletionSource.TrySetResult(true) signaled completion before Interlocked.Exchange(ref finalValue, value) updated finalValue with the final message. The main test thread would wake up and read finalValue before it contained the final state.
Starting with message (19, 19):
server -> value.ServerValue++; // Server: (19,19) → (20,19)
server -> server.TrySendMessage(value) // Sends (20,19) to client
client -> value.ClientValue++; // Client: (20,19) → (20,20)
client -> Interlocked.Exchange(ref finalValue, value); // ✅ Stores (20,20)
client -> clientTaskCompletion.TrySetResult(true); // ✅ Signals client done
server -> Interlocked.Exchange(ref finalValue, value); // ❌ Stores (20,19) - OVERWRITES!
server -> serverTaskCompletion.TrySetResult(true); // ✅ Signals server done
Implementation details
Moved Interlocked.Exchange(ref finalValue, value) outside the if (value < maxNumber) conditional blocks in both server and client callbacks (IpcTests.cs:42 and IpcTests.cs:62). Now every received message updates finalValue, not just messages with values < 20.
This ensures that when TaskCompletionSource signals completion, finalValue is guaranteed to contain the most recent message state.
Test coverage
Other details