KAFKA-7104: Handle leader's log start offset beyond last fetched offset#5302
KAFKA-7104: Handle leader's log start offset beyond last fetched offset#5302apovzner wants to merge 1 commit intoapache:trunkfrom
Conversation
ijuma
left a comment
There was a problem hiding this comment.
Can we not do this check on the leader instead? Seems like clients could also be exposed to this broken invariant.
|
@ijuma clients will not have that issue -- the race happens because the leader first reads log & creates log result Specifically, in ReplicaManager.fetchMessages(): |
|
Build failed: kafka.api.SaslSslAdminClientIntegrationTest > testReplicaCanFetchFromLogStartOffsetAfterDeleteRecords FAILED, which looks unrelated: |
|
The java consumer doesn't really use the start offset, but that may not be true for all clients? I was wondering if we should just use min(fetchOffset, startOffset) as the start offset in the fetch response. |
|
Sorry, that's not quite what I meant. I guess the problem is that it is difficult to determine the first offset of the fetched data in the general case. It is easy for the new message format, but we also have that edge case where the start offset falls in the middle of a batch to be concerned about... Maybe the requirement should be that the start offset cannot be larger than end offset of the first batch or something like that. |
|
@hachikuji as I mentioned in the earlier comment, the issue with inconsistency in fetch result happens only for the fetch from the follower. For the client, the fetch result is creates once when log is read and represents the state at that time, which means that log start offset cannot be higher than first fetched offset returned to the client. Are you suggesting to bound leader's log start offset in fetch response on the leader instead of the follower? Or both? Another option on the follower would be treat the offset out of range from |
|
@apovzner Yeah, I was suggesting to fix the problem on the leader. It seems more ideal if the fetch response is at least internally consistent. Out of curiosity, why are the behaviors different for the follower and the consumer? |
|
I opened another PR to fix the problem on the leader instead of follower: #5305 |
Leader replica may return log start offset in the fetch response that is higher then last fetched offset. This may happen if the log start offset on the leader moves while the fetch response is being build (eg., due to rolling and deleting old segments, or deleting records). This PR limits setting log start offset on the follower to its LEO.
Committer Checklist (excluded from commit message)