Revert "[r3.4] logger: avoid mutex contention"#20652
Merged
Merged
Conversation
This reverts commit 26be98b.
Contributor
There was a problem hiding this comment.
LGTM. The revert makes sense on release/3.4. The earlier change optimized away synchronization in StreamHandler/rotatingWriter, but the stuck stacks here point to blocking writes on stderr/os.File.Write and fdMutex serialization in the runtime. Restoring SyncHandler at the StreamHandler boundary and reinstating rotatingWriter locking is the safer behavior for production logging, even if it gives up the no-contention benchmark path.
AskAlexSharov
added a commit
that referenced
this pull request
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reverts #20487
reason: gnosis has regression
The rotatingWriter.mu does guard the file — it wraps both Write and Close. But a mutex doesn't make the write non-blocking. It just serializes access. If
r.file.Write() blocks in the kernel (pipe full), r.mu stays locked and other goroutines pile up at r.mu.Lock().
But this isn't the current problem. Look at the stuck goroutine stacks — they go through streamHandler directly to os.File.Write(). None of them go through
rotatingWriter. They're writing to stdout or stderr (plain os.File, no rotating writer, no mutex).
The node is set up with log.Root().SetHandler(... log.StderrHandler) — just a streamHandler wrapping os.Stderr. No mutex, no rotation. Multiple goroutines
call os.Stderr.Write() concurrently, serialize at the internal fdMutex, and one of them is stuck in the kernel write() syscall.
So: rotatingWriter.mu is correct but irrelevant to this bug. The bug is the stderr StreamHandler has no Go-level protection and when the stderr pipe
consumer backs up, the kernel write stalls the execution goroutine.