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
KAFKA-15607:Possible NPE is thrown in MirrorCheckpointTask #14587
Conversation
Hi, @clolov. Excuse me, can you help me trigger the build for this PR? I'm also collaborator, why can't I find a place to trigger build PR :) |
connect/mirror/src/test/java/org/apache/kafka/connect/mirror/MirrorCheckpointTaskTest.java
Outdated
Show resolved
Hide resolved
Thanks @hudeqi, I think this is reasonable. Do you know why Sarama sets offsets to -1? If it's for normal operations and not indicative of something wrong, we may not even need to log a warning message in that case and could change the check here from |
…irrorCheckpointTaskTest.java Co-authored-by: Chris Egerton <fearthecellos@gmail.com>
Thanks your review. @C0urante . In fact, directly resetting to -1 is an abnormal operation, whether for Sarama or other clients. This problem was discovered in this way: when using the Sarama client, we wanted to reset the group's offset to the latest, so we passed in the |
Makes sense, thanks for the explanation @hudeqi! |
Reviewers: Chris Egerton <chrise@aiven.io>
Reviewers: Chris Egerton <chrise@aiven.io>
…#14587) Reviewers: Chris Egerton <chrise@aiven.io>
…#14587) Reviewers: Chris Egerton <chrise@aiven.io>
In the
syncGroupOffset
method, iftargetConsumerOffset.get(topicPartition)
gets null, then the calculation oflatestDownstreamOffset
will throw NPE. This usually occurs in this situation: a group consumed a topic in the target cluster previously. Later, the group offset of some partitions was reset to -1, theOffsetAndMetadata
of these partitions was null.It is possible that when reset offsets are performed in the java kafka client, the reset to -1 will be intercepted. However, there are some other types of clients such as sarama, which can magically reset the group offset to -1, so MM2 will trigger an NPE exception in this scenario. Therefore, a defensive measure to avoid NPE is needed here.