-
Notifications
You must be signed in to change notification settings - Fork 241
Allow flush to be used multiple times #1051
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1051 +/- ##
==========================================
+ Coverage 86.71% 86.86% +0.15%
==========================================
Files 55 55
Lines 5804 5840 +36
==========================================
+ Hits 5033 5073 +40
+ Misses 629 624 -5
- Partials 142 143 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Race Condition in Start and Flush Methods
A race condition exists between the Flush()
and Start()
methods. If Flush()
is called before the run()
goroutine (launched by Start()
) has started and reached its select
statement, the send operation on the unbuffered flushCh
will block indefinitely, leading to a deadlock. This occurs because Start()
does not wait for the run()
goroutine to be ready to receive.
batch_logger.go#L40-L51
Lines 40 to 51 in 49dd461
func (l *BatchLogger) Flush(timeout <-chan struct{}) { | |
done := make(chan struct{}) | |
select { | |
case l.flushCh <- done: | |
select { | |
case <-done: | |
case <-timeout: | |
} | |
case <-timeout: | |
} | |
} |
Bug: BatchLogger Shutdown Not Triggered on Close
The Client.Close()
method fails to shut down the batchLogger
's background goroutine, causing a goroutine leak. This occurs because Client.Flush()
was modified to no longer terminate the batchLogger
, but Client.Close()
was not updated to explicitly call client.batchLogger.Shutdown()
.
client.go#L551-L554
Lines 551 to 554 in 49dd461
// otherwise some events may be lost. | |
func (client *Client) Close() { | |
client.Transport.Close() | |
} |
Was this report helpful? Give feedback by reacting with 👍 or 👎
Description
Hotfix for flush only being able to be called once.