#42316 Wait for run goroutine to exit before Close#42320
Merged
Conversation
Contributor
Author
|
#42316 should be fixed by this. This panic is being caused by the fluentd-golang-logger not being defensive about the close of its channel. A comparable implementation of splunk actually uses a RWMutex to solve this problem, But this fix would solve the problem for both underlying drivers not needing any synchronization primitives. |
anujva
force-pushed
the
fix_moby_ring_logger
branch
3 times, most recently
from
April 25, 2021 11:38
40cefda to
13802e5
Compare
run goroutine to exit before Closerun goroutine to exit before Close
cpuguy83
requested changes
Apr 30, 2021
anujva
force-pushed
the
fix_moby_ring_logger
branch
from
April 30, 2021 23:07
13802e5 to
d2fadac
Compare
cpuguy83
reviewed
Apr 30, 2021
anujva
force-pushed
the
fix_moby_ring_logger
branch
from
April 30, 2021 23:42
d2fadac to
7109e4e
Compare
The underlying Loggers Close() function can be called with the the run() goroutine still writing to the driver. This is causing the fluentd-golang-logger to panic cause it doesn't defensively check for the closing of the channel before writing to it. It relies on the docker daemon to keep the contract of not calling Log() if Close() has already been called. Contributions by: James Johnston <[email protected]> Nathan Wong <[email protected]> Signed-off-by: Anuj Varma <[email protected]>
anujva
force-pushed
the
fix_moby_ring_logger
branch
from
May 1, 2021 00:23
7109e4e to
cf259eb
Compare
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.
Fixes #42316
The underlying Loggers Close(), function can be called with the the
run() goroutine still writing to the driver.
This is causing the fluentd-golang-logger to panic cause it doesn't
defensively check for the closing of the channel before writing to it.
It relies on the docker daemon to keep the contract of not calling Log()
if Close() has already been called.
- What I did
Synchronize the close of the underlying logger only after the run goroutine has exited.
- How I did it
Added a sync.Waitgroup to be instantiated withe the RingLogger and then added a wait condition of the goroutine to exit,
before Close is called on the underlying logger.
- How to verify it
I am not sure how best to verify it. Let me know if I should add a unit test for this change or something.
- Description for the changelog
Fixes the race condition between RingLogger Close() and run() goroutine.
- A picture of a cute animal (not mandatory but encouraged)
