dajac commented on code in PR #14985:
URL: https://github.com/apache/kafka/pull/14985#discussion_r1426845969


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java:
##########
@@ -892,6 +895,43 @@ public void replay(
         }
     }
 
+    /**
+     * Applies the given transaction marker.
+     *
+     * @param producerId    The producer id.
+     * @param result        The result of the transaction.
+     * @throws RuntimeException if the transaction can not be completed.
+     */
+    public void completeTransaction(
+        long producerId,
+        TransactionResult result
+    ) throws RuntimeException {
+        Offsets pendingOffsets = 
pendingTransactionalOffsets.remove(producerId);
+
+        if (result == TransactionResult.COMMIT) {
+            log.debug("Committed transactional offset commits for producer id 
{}.", producerId);
+            if (pendingOffsets == null) return;
+
+            pendingOffsets.offsetsByGroup.forEach((groupId, topicOffsets) -> {
+                topicOffsets.forEach((topicName, partitionOffsets) -> {
+                    partitionOffsets.forEach((partitionId, offsetAndMetadata) 
-> {
+                        log.debug("Committed transaction offset commit for 
producer id {} in group {} " +
+                            "with topic {}, partition {}, and offset {}.",
+                            producerId, groupId, topicName, partitionId, 
offsetAndMetadata);
+                        offsets.put(
+                            groupId,
+                            topicName,
+                            partitionId,
+                            offsetAndMetadata
+                        );

Review Comment:
   1. That's correct.
   2. That's correct.
   
   >  i think i'm confused on actually how we differentiate a replicated end 
txn marker from an end txn marker that was only appended to the leader.
   
   It works like any writes. We rely on the HWM to decide. When the end marker 
is processed, we transition the pending offsets to the main offsets map. This 
change is only committed (from a timeline data structure point of view) when 
the HWM advanced and commit the snapshot.



-- 
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-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to