-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-14095: Improve handling of sync offset failures in MirrorMaker #12432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,9 +17,11 @@ | |
| package org.apache.kafka.connect.mirror; | ||
|
|
||
| import org.apache.kafka.clients.admin.Admin; | ||
| import org.apache.kafka.clients.admin.AlterConsumerGroupOffsetsResult; | ||
| import org.apache.kafka.clients.admin.ConsumerGroupDescription; | ||
| import org.apache.kafka.common.ConsumerGroupState; | ||
| import org.apache.kafka.common.KafkaFuture; | ||
| import org.apache.kafka.common.errors.UnknownMemberIdException; | ||
| import org.apache.kafka.connect.source.SourceTask; | ||
| import org.apache.kafka.connect.source.SourceRecord; | ||
| import org.apache.kafka.connect.data.Schema; | ||
|
|
@@ -306,7 +308,16 @@ Map<String, Map<TopicPartition, OffsetAndMetadata>> syncGroupOffset() { | |
|
|
||
| void syncGroupOffset(String consumerGroupId, Map<TopicPartition, OffsetAndMetadata> offsetToSync) { | ||
| if (targetAdminClient != null) { | ||
| targetAdminClient.alterConsumerGroupOffsets(consumerGroupId, offsetToSync); | ||
| AlterConsumerGroupOffsetsResult result = targetAdminClient.alterConsumerGroupOffsets(consumerGroupId, offsetToSync); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: would it also be useful to have a log line here indicating that we're attempting to sync offsets?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Scheduler prints an So I'll leave it like this for now. |
||
| result.all().whenComplete((v, throwable) -> { | ||
| if (throwable != null) { | ||
| if (throwable.getCause() instanceof UnknownMemberIdException) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How stable is the API for the exceptions we'll see here? Can we be reasonably certain that the exception we want to examine will always be wrapped?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The outer exception depends how the future is completed but I think the actual error should always be wrapped.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took a closer look at the The docs for
Given this, we know that The method signatures for So, I'm convinced that we can expect this wrapping 👍 |
||
| log.warn("Unable to sync offsets for consumer group {}. This is likely caused by consumers currently using this group in the target cluster.", consumerGroupId); | ||
| } else { | ||
| log.error("Unable to sync offsets for consumer group {}.", consumerGroupId, throwable); | ||
| } | ||
| } | ||
| }); | ||
| log.trace("sync-ed the offset for consumer group: {} with {} number of offset entries", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we update this log message since it's not guaranteed that the sync will have completed by this point, or that it will even complete successfully at all? Or alternatively, could we keep the message as-is, but move it into an
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've moved it in an |
||
| consumerGroupId, offsetToSync.size()); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When would we encounter this error? My understanding is that it'll only be returned when the broker receives a request with a group instance ID defined, and IIUC it's not possible to define one with the admin API we expose right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, currently this error code is not expected as the admin client does not set the group instance ID. I've removed it.