Skip to content

Conversation

@NachoEchevarria
Copy link
Collaborator

@NachoEchevarria NachoEchevarria commented Dec 24, 2025

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

@github-actions github-actions bot added the area:tests unit tests, integration tests label Dec 24, 2025
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Dec 24, 2025

⚠️ Tests

Fix all issues with Cursor

⚠️ Warnings

🧪 1 Test failed

AzureFunctionsTests+IsolatedRuntimeV4.SubmitsTraces from Datadog.Trace.ClrProfiler.IntegrationTests (Datadog) (Fix with Cursor)
Expected collection to contain at least 21 item(s) because we want to ensure that we don't timeout while waiting for spans from the mock tracer agent, but found 16: {{TraceId: 877066458222606922, SpanId: 6507028377982527990, Name: Manual inside Simple, Resource: Manual inside Simple, Service: AzureFunctionsAllTriggers}, {TraceId: 877066458222606922, SpanId: 11577454305704245678, Name: azure_functions.invoke, Resource: Http SimpleHttpTrigger, Service: AzureFunctionsAllTriggers}, {TraceId: 877066458222606922, SpanId: 6594328968075560746, Name: Manual inside Exception, Resource: Manual inside Exception, Service: AzureFunctionsAllTriggers}, {TraceId: 877066458222606922, SpanId: 8737574236291290481, Name: azure_functions.invoke, Resource: Http Exception, Service: AzureFunctionsAllTriggers}, {TraceId: 877066458222606922, SpanId: 11406793047621095328, Name: Manual inside ServerError, Resource: Manual inside ServerError, Service: AzureFunctionsAllTriggers}, {TraceId: 877066458222606922, SpanId: 5229172151433227532, Name: azure_functions.invoke, Resource: Http ServerError, Service: AzureFunctionsAllTriggers}, {TraceId: 877066458222606922, SpanId: 5012208118664429469, Name: Manual inside BadRequest, Resource: Manual inside BadRequest, Service: AzureFunctionsAllTriggers}, {TraceId: 877066458222606922, SpanId: 11017869350376731143, Name: azure_functions.invoke, Resource: Http BadRequest, Service: AzureFunctionsAllTriggers}, {TraceId: 877066458222606922, SpanId: 7525924178846797149, Name: http.request, Resource: GET localhost:7071/api/simple, Service: AzureFunctionsAllTriggers-http-client}, {TraceId: 877066458222606922, SpanId: 7950879672979771775, Name: http.request, Resource: GET localhost:7071/api/exception, Service: AzureFunctionsAllTriggers-http-client}, {TraceId: 877066458222606922, SpanId: 10177519015026229417, Name: http.request, Resource: GET localhost:7071/api/error, Service: AzureFunctionsAllTriggers-http-client}, {TraceId: 877066458222606922, SpanId: 4736763296822650494, Name: http.request, Resource: GET localhost:7071/api/badrequest, Service: AzureFunctionsAllTriggers-http-client}, {TraceId: 877066458222606922, SpanId: 14764110939188515808, Name: Manual inside Trigger, Resource: Manual inside Trigger, Service: AzureFunctionsAllTriggers}, {TraceId: 877066458222606922, SpanId: 11958796476579138202, Name: azure_functions.invoke, Resource: Http TriggerCaller, Service: AzureFunctionsAllTriggers}, {TraceId: 877066458222606922, SpanId: 3218121321216852130, Name: http.request, Resource: GET localhost:7071/api/trigger, Service: AzureFunctionsAllTriggers-http-client}, {TraceId: 877066458222606922, SpanId: 17790083854230106833, Name: azure_functions.invoke, Resource: Timer TriggerAllTimer, Service: AzureFunctionsAllTriggers}}.

ℹ️ Info

❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 29f6b94 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@dd-trace-dotnet-ci-bot
Copy link

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (8013) and master.

✅ No regressions detected - check the details below

Full Metrics Comparison

FakeDbCommand

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration68.48 ± (68.57 - 68.90) ms68.40 ± (68.45 - 68.68) ms-0.1%
.NET Framework 4.8 - Bailout
duration72.26 ± (72.22 - 72.38) ms72.13 ± (72.08 - 72.35) ms-0.2%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1002.97 ± (1014.48 - 1025.10) ms1004.36 ± (1006.70 - 1012.89) ms+0.1%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms22.02 ± (21.99 - 22.05) ms21.86 ± (21.84 - 21.88) ms-0.7%
process.time_to_main_ms78.84 ± (78.68 - 79.01) ms78.57 ± (78.44 - 78.70) ms-0.3%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.93 ± (10.92 - 10.93) MB10.93 ± (10.92 - 10.93) MB-0.0%
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms21.88 ± (21.85 - 21.91) ms21.81 ± (21.78 - 21.84) ms-0.3%
process.time_to_main_ms80.12 ± (80.02 - 80.22) ms79.93 ± (79.81 - 80.05) ms-0.2%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.96 ± (10.96 - 10.97) MB10.97 ± (10.96 - 10.97) MB+0.0%✅⬆️
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms249.72 ± (245.35 - 254.09) ms242.59 ± (238.45 - 246.74) ms-2.9%
process.time_to_main_ms470.28 ± (469.85 - 470.72) ms469.48 ± (469.03 - 469.93) ms-0.2%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.21 ± (48.19 - 48.24) MB48.20 ± (48.18 - 48.22) MB-0.0%
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.0%
.NET 6 - Baseline
process.internal_duration_ms20.69 ± (20.65 - 20.72) ms20.78 ± (20.75 - 20.80) ms+0.4%✅⬆️
process.time_to_main_ms68.24 ± (68.13 - 68.35) ms68.09 ± (67.99 - 68.19) ms-0.2%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.62 ± (10.62 - 10.63) MB10.65 ± (10.65 - 10.66) MB+0.3%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms20.63 ± (20.60 - 20.65) ms20.72 ± (20.70 - 20.74) ms+0.4%✅⬆️
process.time_to_main_ms69.22 ± (69.16 - 69.28) ms69.07 ± (69.02 - 69.11) ms-0.2%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.74 ± (10.73 - 10.74) MB10.73 ± (10.72 - 10.74) MB-0.1%
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms243.52 ± (240.83 - 246.21) ms243.43 ± (241.00 - 245.86) ms-0.0%
process.time_to_main_ms439.34 ± (438.90 - 439.77) ms441.73 ± (441.28 - 442.19) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.64 ± (48.60 - 48.68) MB48.64 ± (48.61 - 48.67) MB-0.0%
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.0%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms18.92 ± (18.89 - 18.95) ms18.78 ± (18.76 - 18.81) ms-0.7%
process.time_to_main_ms67.38 ± (67.28 - 67.49) ms67.13 ± (67.03 - 67.24) ms-0.4%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.69 ± (7.68 - 7.70) MB7.67 ± (7.67 - 7.68) MB-0.2%
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms18.88 ± (18.86 - 18.91) ms18.92 ± (18.90 - 18.95) ms+0.2%✅⬆️
process.time_to_main_ms68.26 ± (68.20 - 68.32) ms68.50 ± (68.43 - 68.57) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.75 ± (7.74 - 7.76) MB7.73 ± (7.73 - 7.74) MB-0.2%
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms180.76 ± (179.78 - 181.74) ms178.16 ± (177.25 - 179.06) ms-1.4%
process.time_to_main_ms424.61 ± (424.05 - 425.17) ms424.82 ± (424.17 - 425.47) ms+0.0%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed36.32 ± (36.29 - 36.36) MB36.32 ± (36.29 - 36.35) MB-0.0%
runtime.dotnet.threads.count27 ± (27 - 27)27 ± (27 - 27)+0.3%✅⬆️

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration192.84 ± (192.77 - 193.64) ms199.22 ± (198.51 - 199.96) ms+3.3%✅⬆️
.NET Framework 4.8 - Bailout
duration196.81 ± (196.68 - 197.31) ms201.44 ± (201.37 - 202.36) ms+2.3%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1112.38 ± (1117.59 - 1127.01) ms1117.30 ± (1120.70 - 1129.95) ms+0.4%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms187.72 ± (187.34 - 188.10) ms190.30 ± (189.83 - 190.77) ms+1.4%✅⬆️
process.time_to_main_ms80.58 ± (80.35 - 80.81) ms81.43 ± (81.19 - 81.66) ms+1.1%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.19 ± (16.17 - 16.22) MB16.06 ± (16.03 - 16.09) MB-0.8%
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)-0.4%
.NET Core 3.1 - Bailout
process.internal_duration_ms187.61 ± (187.20 - 188.03) ms189.32 ± (188.87 - 189.76) ms+0.9%✅⬆️
process.time_to_main_ms82.09 ± (81.90 - 82.28) ms82.79 ± (82.61 - 82.96) ms+0.9%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.13 ± (16.10 - 16.16) MB16.15 ± (16.13 - 16.17) MB+0.1%✅⬆️
runtime.dotnet.threads.count21 ± (21 - 21)21 ± (21 - 21)-0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms420.13 ± (416.73 - 423.53) ms420.86 ± (417.35 - 424.37) ms+0.2%✅⬆️
process.time_to_main_ms471.63 ± (471.03 - 472.23) ms477.20 ± (476.32 - 478.07) ms+1.2%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.60 ± (58.48 - 58.72) MB58.57 ± (58.45 - 58.68) MB-0.1%
runtime.dotnet.threads.count29 ± (29 - 30)30 ± (29 - 30)+0.2%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms192.94 ± (192.48 - 193.39) ms194.70 ± (194.22 - 195.19) ms+0.9%✅⬆️
process.time_to_main_ms70.00 ± (69.82 - 70.18) ms70.61 ± (70.41 - 70.80) ms+0.9%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.21 ± (16.10 - 16.32) MB16.36 ± (16.33 - 16.38) MB+0.9%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+1.5%✅⬆️
.NET 6 - Bailout
process.internal_duration_ms191.11 ± (190.86 - 191.37) ms194.10 ± (193.69 - 194.50) ms+1.6%✅⬆️
process.time_to_main_ms70.62 ± (70.53 - 70.70) ms71.93 ± (71.74 - 72.12) ms+1.9%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.18 ± (16.04 - 16.32) MB16.27 ± (16.15 - 16.38) MB+0.6%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)20 ± (19 - 20)+2.5%✅⬆️
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms456.13 ± (454.32 - 457.94) ms457.48 ± (454.95 - 460.02) ms+0.3%✅⬆️
process.time_to_main_ms444.92 ± (444.42 - 445.42) ms449.22 ± (448.49 - 449.95) ms+1.0%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed58.34 ± (58.23 - 58.45) MB58.29 ± (58.16 - 58.41) MB-0.1%
runtime.dotnet.threads.count30 ± (29 - 30)30 ± (30 - 30)+0.3%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms190.24 ± (189.91 - 190.57) ms191.45 ± (191.04 - 191.85) ms+0.6%✅⬆️
process.time_to_main_ms69.32 ± (69.15 - 69.49) ms69.91 ± (69.70 - 70.12) ms+0.9%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.76 ± (11.73 - 11.78) MB11.69 ± (11.67 - 11.72) MB-0.5%
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)+0.2%✅⬆️
.NET 8 - Bailout
process.internal_duration_ms190.36 ± (189.98 - 190.75) ms192.83 ± (192.36 - 193.30) ms+1.3%✅⬆️
process.time_to_main_ms70.67 ± (70.54 - 70.81) ms71.30 ± (71.12 - 71.48) ms+0.9%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.80 ± (11.77 - 11.83) MB11.77 ± (11.75 - 11.79) MB-0.3%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.4%✅⬆️
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms364.20 ± (362.64 - 365.76) ms369.16 ± (367.90 - 370.41) ms+1.4%✅⬆️
process.time_to_main_ms427.44 ± (426.91 - 427.97) ms434.91 ± (434.08 - 435.75) ms+1.7%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed47.96 ± (47.92 - 47.99) MB48.06 ± (48.04 - 48.09) MB+0.2%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)-0.1%
Comparison explanation

Execution-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:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

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 charts
FakeDbCommand (.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

Loading
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

Loading
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

Loading
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

Loading
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

Loading
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

Loading
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

Loading
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

Loading

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

Labels

area:tests unit tests, integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants