Repository navigation
Stop RedisHandler blocking logging calls and holding back buffered records - #742
Merged
Merged
Conversation
disable_buffering() left the buffered records in place, and emit() pushed only when the buffer held exactly flush_threshold records. Once the threshold dropped to 1, records stayed buffered until close().
RedisHandler pushed while holding its lock, so logging calls waited whenever a push to an unreachable Redis was in progress. A failed push also killed the flush thread, and closing during a flush could push records twice.
Merging this PR will not alter performance1 warning
Comparing |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #742 +/- ##
==========================================
+ Coverage 91.40% 91.65% +0.25%
==========================================
Files 49 49
Lines 7931 8098 +167
Branches 609 619 +10
==========================================
+ Hits 7249 7422 +173
+ Misses 546 542 -4
+ Partials 136 134 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
RedisHandlerpushed to Redis while holding its lock, so logging calls waited whenever a push to an unreachable Redis was in progress. A failed push killed the flush thread. After that, records went out only when the buffer held exactlyflush_thresholdof them, and once a push there had failed, not untilclose().disable_buffering()also left buffered records untilclose(), and closing during a flush could push records twice.While buffering, the flush thread is now the only pusher. It holds no lock during the push and keeps a failed batch for the next attempt. The next logging call reports the first failure in a row through the handler's
handle_error().close()anddisable_buffering()push what is buffered and raise if that fails. In a forked child, the handler starts a new flush thread when it first logs.