Shekharrajak commented on code in PR #22357:
URL: https://github.com/apache/kafka/pull/22357#discussion_r3390030405


##########
core/src/main/java/kafka/server/share/SharePartition.java:
##########
@@ -1051,6 +1052,116 @@ public CompletableFuture<Void> acknowledge(
         return future;
     }
 
+    public CompletableFuture<Void> stageTxnAcknowledge(
+        String memberId,
+        long producerId,
+        short producerEpoch,
+        List<ShareAcknowledgementBatch> acknowledgementBatches
+    ) {
+        log.trace("Txn stage request for share partition: {}-{} 
producerId={}", groupId, topicIdPartition, producerId);
+
+        CompletableFuture<Void> future = new CompletableFuture<>();
+        Throwable throwable = null;
+        lock.writeLock().lock();
+        try {
+            for (ShareAcknowledgementBatch batch : acknowledgementBatches) {
+                Map<Long, Byte> ackTypeMap;
+                try {
+                    ackTypeMap = fetchAckTypeMapForBatch(batch);
+                } catch (IllegalArgumentException e) {
+                    throwable = new InvalidRequestException("Invalid 
acknowledge type: " + batch.acknowledgeTypes());
+                    break;
+                }
+
+                for (Byte ackType : ackTypeMap.values()) {
+                    if (ackType != AcknowledgeType.ACCEPT.id && ackType != 
AcknowledgeType.REJECT.id) {
+                        throwable = new InvalidRequestException("Only ACCEPT 
or REJECT permitted in transactional ack");
+                        break;
+                    }
+                }
+                if (throwable != null) break;
+
+                if (batch.lastOffset() < startOffset) continue;
+
+                NavigableMap<Long, InFlightBatch> subMap;
+                try {
+                    subMap = fetchSubMapForAcknowledgementBatch(batch);
+                } catch (InvalidRecordStateException | InvalidRequestException 
e) {
+                    throwable = e;
+                    break;
+                }
+
+                throwable = stageBatchTxnRecords(memberId, producerId, 
producerEpoch, batch, ackTypeMap, subMap);
+                if (throwable != null) break;

Review Comment:
   Transactional REJECT received
       -> validate ownership/session/producer fencing
       -> persist pending transactional reject
       -> no DLQ write yet
   
     Transaction COMMIT marker
       -> materialize REJECT
       -> if DLQ disabled: ARCHIVED
       -> if DLQ enabled: ARCHIVING, then DLQ enqueue, then ARCHIVED
   
     Transaction ABORT marker
       -> discard pending REJECT
       -> no DLQ write
       -> record becomes retryable according to share lock/member rules
   



-- 
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]

Reply via email to