Repository navigation
output: skip retry waits when shutting down - #5687
Conversation
Signed-off-by: FayezBast <fayezbast15@gmail.com>
Watson1978
left a comment
There was a problem hiding this comment.
Thanks for fixing #5683.
The flush thread now checks the stop flag while it holds state.mutex, and after_shutdown signals under the same mutex. So the thread no longer misses a stop that starts during a write. When the flag was false, the old loop also exited at its next check, right after the wait. This change only skips that final wait, which can be the wait for the next retry or the normal flush interval.
On affb1d0, the new test fails because the thread calls wait with a timeout of about 60 seconds. It passes on this branch. With the slow failing output from the issue, a stop during a write took 17.5 seconds on master and under two seconds here, with one or two flush threads. With a file buffer, the failed chunk was kept, and every record was delivered once after a restart.
…5696) <!-- Thank you for contributing to Fluentd! Your commits need to follow DCO: https://probot.github.io/apps/dco/ And please provide the following information to help us make the most of your pull request: --> **Which issue(s) this PR fixes**: Backport #5687 Fixes #5683 **What this PR does / why we need it**: If a buffered output write fails during shutdown, the flush thread can miss the shutdown signal and wait for the next retry, delaying worker exit. Recheck the stop flag while holding the flush thread mutex before entering the retry wait. The regression test verifies that the thread skips the wait and the failed chunk stays queued. In a live Fluentd test with a two-second HTTP read timeout and a six-second retry interval, shutdown time dropped from 8.05 seconds to 2.02 seconds. A separate file-buffer test confirmed that the preserved record was delivered once after restart. The affected suites ran 407 tests with zero failures or errors and three Windows-only omissions. **Docs Changes**: None. **Release Note**: Fluentd skips the retry wait when an in-flight buffered output write fails during shutdown. Signed-off-by: FayezBast <fayezbast15@gmail.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Fayez Bast <96446332+FayezBast@users.noreply.github.com>
Which issue(s) this PR fixes:
Fixes #5683
What this PR does / why we need it:
If a buffered output write fails during shutdown, the flush thread can miss the shutdown signal and wait for the next retry, delaying worker exit.
Recheck the stop flag while holding the flush thread mutex before entering the retry wait. The regression test verifies that the thread skips the wait and the failed chunk stays queued.
In a live Fluentd test with a two-second HTTP read timeout and a six-second retry interval, shutdown time dropped from 8.05 seconds to 2.02 seconds. A separate file-buffer test confirmed that the preserved record was delivered once after restart. The affected suites ran 407 tests with zero failures or errors and three Windows-only omissions.
Docs Changes:
None.
Release Note:
Fluentd skips the retry wait when an in-flight buffered output write fails during shutdown.