Add commit_after_pq_fsync: commit Kafka offsets only after the persistent queue fsyncs - #272
Draft
LolloneS wants to merge 7 commits into
Draft
Add commit_after_pq_fsync: commit Kafka offsets only after the persistent queue fsyncs#272LolloneS wants to merge 7 commits into
LolloneS wants to merge 7 commits into
Conversation
…int! Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…tart When checkpoint! raised an IO error, the exception hit the Java Thread boundary and was lost: run returned normally, the inputworker saw no exception, and with the default consumer_threads=1 the pipeline silently consumed nothing forever. Capture unexpected thread failures in a CopyOnWriteArrayList and re-raise the first one from run after all threads have joined. Errors during orderly shutdown (stop? true) are suppressed. The inputworker now retries the input on checkpoint failure, consistent with how it handles other input errors. Update the 'does not commit offsets when checkpoint! raises' spec to assert that run surfaces the error rather than returning normally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The fsync briefly blocks all other inputs in the pipeline. Recommend running in a dedicated pipeline to avoid unintended throughput contention. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
What does this PR do?
Adds an opt-in
commit_after_pq_fsyncboolean option (defaultfalse) to the Kafka input. When enabled, each poll batch is fsynced to Logstash's persistent queue before the corresponding offsets are committed to the broker:commit_after_pq_fsync, documented indocs/input-kafka.asciidoc.queue.type: persisted(read via the execution context's pipeline settings) and raisesLogStash::ConfigurationErrorotherwise — validation happens inregisterbecauseregisterfailures abort pipeline startup, while exceptions fromrunare retried forever by the pipeline's inputworker. Also forcesenable_auto_committofalse(with a warning if it was explicitlytrue), since the Kafka client's background committer would bypass the fsync gate.ConfigurationErrorwhen the queue write client predates thecheckpoint!API (older Logstash), instead of a mid-streamNoMethodError.thread_runner, after pushing a batch and beforemaybe_commit_offset, the plugin callslogstash_queue.checkpoint!. On checkpoint failure the error is logged and re-raised, so offsets are never committed for a batch whose durability is unknown; the consumer closes and its partitions rebalance, and the uncommitted offsets are re-polled.Depends on the core API added in elastic/logstash#19362 (
persistent?/checkpoint!on the queue write client). Version placeholders (X.Yin docs and the guard's error message,#PRin the changelog) will be filled once that PR lands in a release.Why is it important/What is the impact to the user?
With a persistent queue, offsets are currently committed as soon as events reach the PQ's in-memory page buffer — before any fsync — in both commit modes (manual
commitSyncand the client's background auto-commit). A crash between the offset commit and the next PQ checkpoint loses events the broker already considers consumed, breaking at-least-once delivery. This option closes that window at poll-batch granularity, at the cost of one fsync per batch (increasemax_poll_recordsto amortize).Note on failure behavior: if
checkpoint!fails (e.g. disk full) withconsumer_threads => 1, the input stops consuming while the pipeline stays up, loggingPQ checkpoint failed; Kafka offsets will not be committed, consumer stopping— operators may want to alert on that line. This mirrors the plugin's existing fatal-error paths (e.g.FencedInstanceIdException).Checklist
docs/input-kafka.asciidoc, CHANGELOG, version bump to 12.2.0)🤖 Generated with Claude Code