C0urante commented on PR #14316: URL: https://github.com/apache/kafka/pull/14316#issuecomment-1701929338
I think it's a great idea to pre-signal stop via `Thread::interrupt`. There are a few complications that we'd need to consider but nothing I'm majorly opposed to: - We'd need to handle an [InterruptException](https://kafka.apache.org/35/javadoc/org/apache/kafka/common/errors/InterruptException.html), which is a wrapped variant of `InterruptedException` that can be thrown by Kafka clients (such as the task's producer) - We may want to add checks for whether we've been stopped or not before interacting with any user-written code (converter, transformations, etc.), as opposed to just the `SourceTask` object - IMO, this modifies the contract for the source connector API significantly enough that it's worth at least asking the dev and user lists about, if not a full-on KIP. The signature for `SourceTask::poll` strongly implies that `Thread::interrupt` was at one point an intended mechanism for short-circuiting the source task poll-convert-produce loop, but since we haven't actually followed through on those intentions (yet), it'd be nice to get the input of the community and other Kafka Connect maintainers about whether it's worth it to lock ourselves into that path. Once we start interrupting threads, developers may write new connectors and adjust existing connectors with that change in mind, and we'd be just as likely to introduce a second breaking change in behavior (the first being the one described in [KAFKA-15090](https://issues.apache.org/jira/browse/KAFKA-15090) if we decided to publish a subsequent release that didn't include that logic If this is agreeable to you, I can ping the dev and user lists to check about adding thread interruption, and we can either block this PR on the outcome of that discussion, or merge it as-is and leave thread interruptiong`SourceTask::stop` as a follow-up item pending the outcome of the discussion. I'm okay with either approach, and happy to discuss further if you have a different assessment of the situation. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
