Skip to content

output: skip retry waits when shutting down - #5687

Merged
Watson1978 merged 1 commit into
fluent:masterfrom
FayezBast:fix/output-shutdown-retry
Nov 26, 2026
Merged

Watson1978 merged 1 commit into
fluent:masterfrom
FayezBast:fix/output-shutdown-retry

Conversation

@FayezBast

Copy link
Copy Markdown
Contributor

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.

Signed-off-by: FayezBast <fayezbast15@gmail.com>
@Watson1978 Watson1978 added bug Something isn't working backport to v1.19 We will backport this fix to the LTS branch labels Nov 26, 2026
@Watson1978 Watson1978 added this to the v1.21.0 milestone Nov 26, 2026

@Watson1978 Watson1978 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Watson1978
Watson1978 merged commit 7c3a498 into fluent:master Nov 26, 2026
20 checks passed
Watson1978 pushed a commit that referenced this pull request Nov 30, 2026
…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>
@github-actions github-actions Bot added the backported "backport to LTS" is done label Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport to v1.19 We will backport this fix to the LTS branch backported "backport to LTS" is done bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stopping Fluentd waits until the next retry time when a write is running at shutdown

2 participants