[flink][client] Close writer immediately on sink failover - #3817
Open
naivedogger wants to merge 1 commit into
Open
[flink][client] Close writer immediately on sink failover#3817naivedogger wants to merge 1 commit into
naivedogger wants to merge 1 commit into
Conversation
…-based Connection close
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.
Purpose
Linked issue: close #3809
The Flink sink closed the client via
Connection.close(), which closes the underlyingWriterClientwith an unbounded timeout. With pending records that cannot be sent (e.g. cluster unavailable during failover, with infinite writer retries by default), the sender's drain loop never exits and the task blocks in close, preventing failover from proceeding.Brief change log
Connection: add a timeout-basedclose(Duration)API (default method, delegating toclose()); zero/negative timeout means immediate close, abandoning unsent and in-flight requests.FlussConnection: implementclose(Duration); the no-argclose()keeps the previous graceful semantics (unbounded timeout).WriterClient#close(Duration): a non-positive timeout now force-closes the sender up front instead of initiating a graceful close; when a graceful close times out, force-close the sender before interrupting the io thread, and bound the final wait (5s safety net) instead of reusing the caller timeout.FlinkSinkWriter#close: close the connection withDuration.ZERO. Data correctness is unaffected: records are flushed on checkpoints, and on failover/cancellation un-flushed records are replayed from the last checkpoint. This mirrors Kafka'sFlinkKafkaInternalProducer#close().Tests
FlinkSinkWriterTest#testCloseReturnsPromptlyWhenFlussUnavailable: reproduces the failover scenario (cluster down + pending record + default infinite retries) and asserts close returns promptly. Verified it hangs and fails without the fix.FlinkSinkWriterTesttests still pass, includingtestCloseExceptionWhenFlussUnavailable(close still surfaces async write errors).API and Format
Adds
Connection#close(Duration)as a default method on the@PublicEvolvinginterface; existing implementations and callers are unaffected. No storage format changes.Documentation
No documentation changes.