Repository navigation
out_rdkafka, out_rdkafka2: Fix crash or hang on shutdown with queued messages - #624
Merged
Merged
Conversation
…messages With rdkafka 0.16.0 or later, the patched NativeKafka#close destroyed the handle even when the 10 second wait for the polling thread timed out. The polling thread leaves its loop only when the queue is empty, so it was still running when the brokers could not be reached. close then waited forever for the poll mutex, or the polling thread called rd_kafka_poll with the destroyed handle and the worker crashed with SIGSEGV. When the wait times out, purge the queued and in-flight messages, and wait for the polling thread to finish before destroying the handle. close still returns false in this case, so the "Queue is forcefully closed" warning is logged as before. Fixes fluent#611 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
Contributor
Author
|
The failure in the Ruby 4.0 job with rdkafka
Flaky tests make CI results hard to trust, so I'll investigate this crash separately. |
This was referenced Nov 12, 2026
kenhys
reviewed
Nov 13, 2026
kenhys
approved these changes
Nov 13, 2026
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.
With rdkafka 0.16.0 or later, rdkafka2 and rdkafka crash the worker with SIGSEGV, or never finish the shutdown, when Fluentd stops while the producer queue still has undelivered messages. The patched
NativeKafka#closedestroyed the handle after the 10 second wait timed out, but the polling thread was still running.This PR purges the queue when the wait times out, and waits for the polling thread to stop before destroying the handle. The messages still queued after the wait are dropped, as they were lost on destroy before. The "Queue is forcefully closed after 10 seconds wait" warning is logged as before.
Fixes #611