Repository navigation
[CI Visibility] Fix message loss and abandoned mutexes in the IPC channel - #9335
tonyredondo wants to merge 4 commits into
Conversation
6ff2985 to
8fc4f00
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
BenchmarksBenchmark execution time: 2026-10-23 16:10:31 Comparing candidate commit 94750e5 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 72 metrics, 0 unstable metrics, 6 known flaky benchmarks, 120 flaky benchmarks without significant changes.
|
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (9335) and master. ✅ No regressions detected |
8fc4f00 to
ebb8189
Compare
ebb8189 to
1e14acd
Compare
|
@codex review |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1e14acdcb5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
1e14acd to
bf0693b
Compare
Opening a CircularChannel reset its read and write pointers, so every new IPC client dropped the messages the other side hadn't read yet. Only a new file, or one with an unexpected size, is initialized now.
A completely full buffer was marked with a virtual write position (BufferBodySize + writePos), which overflows the ushort pointer with the default 64 KB buffer. The reader then looped over the same messages forever while holding the lock, until the process ran out of memory. Always keep one byte free instead, so the write position never reaches the read position.
bf0693b to
a84c18a
Compare
…or writing WaitOne grants ownership of an abandoned mutex before it throws AbandonedMutexException. The CircularChannel reader already handled that, but the constructor and the writer let the exception escape, so the call failed and the thread kept owning the mutex, which blocked every other process using the channel. All three paths now share the reader's handling. This resolves the TODO in CheckBuildLogsForErrors, so the ignore patterns for those errors are removed. The pattern for ReleaseMutex failing after a successful wait stays: that one comes from the .NET 11 RC named mutex bug (dotnet/runtime#134491) and goes away with .NET 11 GA.
The reader slept between polls and returned early once the reader or the channel was disposed, so anything written during its last polling interval was dropped. A session that disposes its IPC server right after the last message from a child process could lose that message. The reader now waits on the stop event instead of sleeping, so Dispose wakes it right away, and it polls once more before it stops. Dispose already joins the polling thread before the channel releases the memory mapped file.
a84c18a to
94750e5
Compare
Summary of changes
Fixes four bugs in the CI Visibility IPC channel (
CircularChannel) that lose messages or leave the channel locked:ushortpointer with the default 64 KB buffer. The reader then re-read the same messages forever while holding the lock, until the process ran out of memory.AbandonedMutexExceptionescape. An abandoned wait still transfers ownership, so the thread kept the mutex and every other process using the channel timed out. The reader already handled this ([Test Optimization] Fix MSTest 4.4.0 discovery and native retries #9192).Reason for change
Coverage results, session tags and the executed test count in #9486 all go through this channel, and each of these bugs can lose them. The abandoned-mutex one is the TODO that #9317 left in
CheckBuildLogsForErrors.Implementation details
TryAcquireMutex, which treats an abandoned mutex as acquired and logs a warning. Callers release it as usual. TheCheckBuildLogsForErrorsTODO and its ignore patterns for these errors are removed. The pattern forReleaseMutexfailing after a successful wait stays, with a new comment: that one comes from the .NET 11 RC runtime bug below, and it shows up on Linux ARM64 when a .NET 8-10 test host shares a channel with the .NET 11 VSTest runner.This PR doesn't fix the .NET 11 RC named mutex incompatibility with .NET 8-10 on Unix (dotnet/runtime#134491). That's fixed in the runtime for .NET 11 GA (dotnet/runtime#134595), so the existing .NET 11 test skips stay until we move to GA. An earlier version of this PR replaced the named mutex with a file lock on Unix; I dropped it so we don't maintain a separate lock for a runtime bug that's going away.
Test coverage
New
CircularChannelTests, each checked locally to fail without its fix:OpeningAnExistingChannelKeepsUnreadMessagesBufferNeverFillsCompletelyWithTheDefaultSize: with the default buffer size, a message that would fill the buffer exactly is rejected, and every message is delivered exactly once. The unit tests used an 8 KB buffer, which never overflows.OpeningAChannelAndWritingAcquireAnAbandonedMutexDisposingAReaderReadsMessagesWrittenBeforeItCircularChannelWriteTestnow expects one byte to stay free.Datadog.Trace.Tests.Ci.Ipcpasses locally on Linux with net8.0.Other details
Related: #9317, #9327, dotnet/runtime#134491, dotnet/runtime#134595. #9486 is stacked on this PR.