smjn commented on code in PR #23190:
URL: https://github.com/apache/kafka/pull/23190#discussion_r3803411626
##########
share-coordinator/src/main/java/org/apache/kafka/coordinator/share/ShareCoordinatorShard.java:
##########
@@ -563,15 +563,23 @@ public
CoordinatorResult<InitializeShareGroupStateResponseData, CoordinatorRecor
InitializeShareGroupStateRequestData.PartitionData partitionData =
topicData.partitions().get(0);
SharePartitionKey key =
SharePartitionKey.getInstance(request.groupId(), topicData.topicId(),
partitionData.partition());
- CoordinatorRecord record =
generateInitializeStateRecord(partitionData, key);
- // build successful response if record is correctly created
+ Integer currentStateEpoch = stateEpochMap.get(key);
+ ShareGroupOffset currentState = shareStateMap.get(key);
+
InitializeShareGroupStateResponseData responseData = new
InitializeShareGroupStateResponseData().setResults(
List.of(InitializeShareGroupStateResponse.toResponseInitializeStateResult(key.topicId(),
List.of(InitializeShareGroupStateResponse.toResponsePartitionResult(
key.partition()))
))
);
+ if (currentStateEpoch != null && currentStateEpoch ==
partitionData.stateEpoch() &&
+ currentState != null && currentState.startOffset() ==
partitionData.startOffset()) {
Review Comment:
@apoorvmittal10
Thanks for the review. The validation for < is done in
`maybeGetInitializeStateError` before this executes.
The case we are concerned here is mainly for initializeState retries which
contain exactly same information. Assume 2 initializeState calls i1, i2. Due to
network issue say i1 is executed on share coord correctly but the response does
not arrive at the persister. Persister sends i2 (retry) - this is exactly the
type of case we want ot check here. Same thing if i2 completes but i1 arrives
out of order (stateEpochs are same). This covers ==
For > case, the request could be from alter offsets for which we want to
overwrite state.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]