-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-7211: MM should handle TimeoutException in commitSync #5492
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
0defde1
0228e18
b10c6ac
b0c33b7
e02bf6e
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 |
|---|---|---|
|
|
@@ -39,6 +39,8 @@ import org.apache.kafka.common.record.RecordBatch | |
|
|
||
| import scala.collection.JavaConverters._ | ||
| import scala.collection.mutable.HashMap | ||
| import scala.concurrent.TimeoutException | ||
| import scala.util.{Failure, Success, Try} | ||
| import scala.util.control.ControlThrowable | ||
|
|
||
| /** | ||
|
|
@@ -280,6 +282,10 @@ object MirrorMaker extends Logging with KafkaMetricsGroup { | |
| consumerWrapper.commit() | ||
| throw e | ||
|
|
||
| case _: TimeoutException => | ||
| warn("Failed to commit offsets because the offset commit request processing can not be completed in time. " + | ||
| s"If you see this regularly, it could indicate that you need to increase the consumer's ${ConsumerConfig.DEFAULT_API_TIMEOUT_MS_CONFIG}") | ||
|
|
||
| case _: CommitFailedException => | ||
| warn("Failed to commit offsets because the consumer group has rebalanced and assigned partitions to " + | ||
| "another instance. If you see this regularly, it could indicate that you need to either increase " + | ||
|
|
@@ -473,7 +479,14 @@ object MirrorMaker extends Logging with KafkaMetricsGroup { | |
| } | ||
|
|
||
| def commit() { | ||
| consumer.commitSync(offsets.map { case (tp, offset) => (tp, new OffsetAndMetadata(offset, ""))}.asJava) | ||
| val existingTopics: Set[String] = Try(consumer.listTopics) match { | ||
|
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 do this in case of Timeout error and clear offsets map? Checking for every commit maybe costly.
Contributor
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. @omkreddy Thanks for the response. Currently,
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. With KIP-266, even
Contributor
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. With the
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. We should get Timeout error after default.api.timeout.ms (default 60secs). |
||
| case Success(allTopics) => allTopics.keySet.asInstanceOf[Set[String]] | ||
| case Failure(_) => Set.empty | ||
| } | ||
| if (existingTopics.nonEmpty) | ||
| consumer.commitSync(offsets.filterKeys(tp => existingTopics.contains(tp.topic)).map { case (tp, offset) => (tp, new OffsetAndMetadata(offset, "")) }.asJava) | ||
|
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: we can use
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. Also, split to multiple lines. Typical line width is 120 characters. |
||
| else | ||
| consumer.commitSync(offsets.map { case (tp, offset) => (tp, new OffsetAndMetadata(offset, "")) }.asJava) | ||
|
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: we can use OffsetAndMetadata(long offset) construtor |
||
| offsets.clear() | ||
| } | ||
| } | ||
|
|
||
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.
Related to the concern of data loss, would it be useful to also keep track and log the time of last successful commit in the warning message, so that SRE can gauge how much time worth of data has been duplicated?