[fix][io] Interrupt Kafka Source instance thread on consumer fatal error to prevent deadlock#27
Open
Praveenkumar76 wants to merge 5 commits into
Open
Conversation
…ror to prevent deadlock
…nside the catch block
…survives the GitHub Actions CI
…entire Kafka broker and zookeeper
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.
Fixes apache#25290
Motivation
The Kafka Source connector can enter a liveness failure when its consumer thread encounters a fatal error. In such cases, the connector reports the error via
notifyError(), which relies on the framework’s instance thread to read and handle it.However, if the instance thread is blocked in
sendOutputMessage()(for example, waiting on network I/O to the Pulsar broker), it does not return toreadNext()and therefore never processes the error queue. As a result, the consumer thread terminates, the instance thread remains stuck, and the connector pod continues running without doing useful work. This leads to a “zombie” state where Kubernetes health checks still pass, but the connector is effectively dead.Modifications
instanceThreadreference during theopen()method.runnerThreaderror handling:catchblock andUncaughtExceptionHandler, when a fatal exception occurs, the consumer thread now interrupts theinstanceThread.CompletableFuture.get()or socket wait) insendOutputMessage(), allowing the instance thread to wake up and process the error vianotifyError().consumer.subscribe()outside thewhile (running)loop to properly surface initialization errors.Verifying this change
This change added tests and can be verified as follows:
KafkaSourceDeadlockTest.javasendOutputMessage()in the instance thread.Does this pull request potentially affect one of the following parts: