shibd opened a new pull request, #22511: URL: https://github.com/apache/pulsar/pull/22511
### Motivation The current implementation of Kafka source connector, that `KafkaRecord` does not implement the `fail()` method. https://github.com/apache/pulsar/blob/bbae607fb174d2f6f9b94d897903b8d24cece7dc/pulsar-io/kafka/src/main/java/org/apache/pulsar/io/kafka/KafkaAbstractSource.java#L222 If `PulsarSink` send a message to pulsar failed, will call `record.fail()`. https://github.com/apache/pulsar/blob/43a989862f548fa3f67708a5fff62eb764af878c/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/sink/PulsarSink.java#L194-L196 But because KafkaRecord does not implement it, this `futures` will never end. https://github.com/apache/pulsar/blob/495b141c7bebc0356297546e9db88c9e087f5039/pulsar-io/kafka/src/main/java/org/apache/pulsar/io/kafka/KafkaAbstractSource.java#L178 This causes the Kafka consumer to leave the consumer group due to more than `max.poll.interval.ms`. ```log 2024-04-11T14:06:25,730-0400 [kafka-coordinator-heartbeat-thread | kafka2pulsarConsumer] INFO org.apache.kafka.clients.consumer.internals.AbstractCoordinator - [Consumer clientId=consumer-1, groupId=consumer-g-1] Member consumer-1 sending LeaveGroup request to coordinator localhost:9092 (id: 2147483644 rack: null) due to consumer poll timeout has expired. This means the time between subsequent calls to poll() was longer than the configured max.poll.interval.ms, which typically implies that the poll loop is spending too much time processing messages. You can address this either by increasing max.poll.interval.ms or by reducing the maximum size of batches returned in poll() with max.poll.records. ``` ### Modifications - Implement `fail()` method for `KakfaRecord`. Let `CompletableFuture.allOf(futures).get()` support a timeout, set to 2/3 of `max.poll.interval.ms`. This adjustment is to ensure the interval between two `poll` requests does not exceed Kafka `max.poll.interval.ms`. - When it times out, it will trigger a connector failure, thereby restarting the connector. ### Verifying this change - Add `throwExceptionBySendFail` and `throwExceptionBySendTimeOut ` to cover it. ### Documentation <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. --> - [ ] `doc` <!-- Your PR contains doc changes. --> - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later --> - [ ] `doc-not-needed` <!-- Your PR changes do not impact docs --> - [ ] `doc-complete` <!-- Docs have been already added --> ### Matching PR in forked repository PR in forked repository: <!-- ENTER URL HERE --> <!-- After opening this PR, the build in apache/pulsar will fail and instructions will be provided for opening a PR in the PR author's forked repository. apache/pulsar pull requests should be first tested in your own fork since the apache/pulsar CI based on GitHub Actions has constrained resources and quota. GitHub Actions provides separate quota for pull requests that are executed in a forked repository. The tests will be run in the forked repository until all PR review comments have been handled, the tests pass and the PR is approved by a reviewer. --> -- 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]
