You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "hudeqi (via GitHub)" <gi...@apache.org> on 2024/05/13 10:21:55 UTC
[PR] KAFKA-16710:Continuously `makeFollower` may cause the replica fetcher thread to encounter an offset mismatch exception [kafka]
hudeqi opened a new pull request, #15929:
URL: https://github.com/apache/kafka/pull/15929
**Activation**
As described from [kafka-16710](https://issues.apache.org/jira/browse/KAFKA-16710):
The scenario where this case occurs is during a reassignment of a partition: 110879, 110880 (original leader, original follower) ---> 110879, 110880, 110881, 113915 (the latter two replicas are new leader and new follower) ---> 110881, 113915 (new leader, new follower). The "Offset mismatch" exception occurs on the new follower 113915.
Through analysis, the exception occurs in the reassignment process:
1. After the new replicas 110881, 113915 are fully enqueued into the ISR, the controller will switch the leader from 110879 to 110881, and then send a new `leaderAndIsr` (leader is 110881, ISR is 110879, 110880, 110881, 113915) to 110881, 113915.
2. This time, 110881 executes `makeLeader`, and 113915 executes `makeFollower`. After the new follower 113915 completes `removeFetcherForPartitions` and `addFetcherForPartitions`, it starts fetching data from the new leader 110881, but because the log end offset of the new leader 110881 (18735600055) is smaller than the log end offset of the new follower 113915 (18735600059), the new follower 113915 adds the partition to `divergingEndOffsets` during `processFetchRequest` and then executes `truncateOnFetchResponse` to truncate the local log to 18735600055.
3. However, unfortunately, `truncateOnFetchResponse` needs to acquire the `partitionMapLock` lock, and at the same time, the new leader 110881 and the new follower 113915 also receive another `leaderAndIsr` request from the controller (to remove the old replicas 110879, 110880 from the ISR), and the `ReplicaFetcherManager` thread of the new follower 113915 executes the second `makeFollower` to acquire the `partitionMapLock` lock firstly and execute `removeFetcherForPartitions`, and then gets the local log end offset (18735600059) as the fetch offset, ready to execute `addFetcherForPartitions` again to update the fetch offset (18735600059) to the `partitionStates`.
4. But unfortunately, the follower fetcher thread that was ready to truncate the local log to 18735600055 firstly obtained the `partitionMapLock` lock and completed the truncation, and the log end offset is now 18735600055.
5. Then, the thread that executed the second `makeFollower` obtained the `partitionMapLock` lock and executed `addFetcherForPartitions` to update the outdated fetch offset (18735600059) to the `partitionStates`.
6. Finally, it leads to: the follower thread throws the following exception during `processPartitionData`: "java.lang.IllegalStateException: Offset mismatch for partition aiops-adplatform-interfacelog-191: fetched offset = 18735600059, log end offset = 18735600055."
**Solution**
Move `truncateOnFetchResponse` to the range of `partitionMapLock` in replica fetcher thread.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16710:Continuously `makeFollower` may cause the replica fetcher thread to encounter an offset mismatch exception [kafka]
Posted by "hudeqi (via GitHub)" <gi...@apache.org>.
hudeqi commented on PR #15929:
URL: https://github.com/apache/kafka/pull/15929#issuecomment-2124671194
PTAL, thanks! @showuon
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16710:Continuously `makeFollower` may cause the replica fetcher thread to encounter an offset mismatch exception [kafka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #15929:
URL: https://github.com/apache/kafka/pull/15929#issuecomment-2780176557
This PR is being marked as stale since it has not had any activity in 90 days. If you
would like to keep this PR alive, please leave a comment asking for a review. If the PR has
merge conflicts, update it with the latest from the base branch.
<p>
If you are having difficulty finding a reviewer, please reach out on the
[mailing list](https://kafka.apache.org/contact).
<p>
If this PR is no longer valid or desired, please feel free to close it. If no activity
occurs in the next 30 days, it will be automatically closed.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16710:Continuously `makeFollower` may cause the replica fetcher thread to encounter an offset mismatch exception [kafka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #15929: KAFKA-16710:Continuously `makeFollower` may cause the replica fetcher thread to encounter an offset mismatch exception
URL: https://github.com/apache/kafka/pull/15929
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16710:Continuously `makeFollower` may cause the replica fetcher thread to encounter an offset mismatch exception [kafka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #15929:
URL: https://github.com/apache/kafka/pull/15929#issuecomment-2849835096
This PR has been closed since it has not had any activity in 120 days. If you feel like this
was a mistake, or you would like to continue working on it, please feel free to re-open the
PR and ask for a review.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16710:Continuously `makeFollower` may cause the replica fetcher thread to encounter an offset mismatch exception [kafka]
Posted by "hudeqi (via GitHub)" <gi...@apache.org>.
hudeqi commented on PR #15929:
URL: https://github.com/apache/kafka/pull/15929#issuecomment-2115483193
Hi @dajac , could you help to review this issue?
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16710:Continuously `makeFollower` may cause the replica fetcher thread to encounter an offset mismatch exception [kafka]
Posted by "hudeqi (via GitHub)" <gi...@apache.org>.
hudeqi commented on PR #15929:
URL: https://github.com/apache/kafka/pull/15929#issuecomment-2107199835
If this change is reasonable, I will add the unit test.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16710:Continuously `makeFollower` may cause the replica fetcher thread to encounter an offset mismatch exception [kafka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #15929:
URL: https://github.com/apache/kafka/pull/15929#issuecomment-2300570000
This PR is being marked as stale since it has not had any activity in 90 days. If you would like to keep this PR alive, please ask a committer for review. If the PR has merge conflicts, please update it with the latest from trunk (or appropriate release branch) <p> If this PR is no longer valid or desired, please feel free to close it. If no activity occurs in the next 30 days, it will be automatically closed.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org