adixitconfluent commented on code in PR #19261:
URL: https://github.com/apache/kafka/pull/19261#discussion_r2013589373

##########
core/src/main/java/kafka/server/share/SharePartition.java:
##########
@@ -2484,6 +2497,259 @@ private long startOffsetDuringInitialization(long 
partitionDataStartOffset) thro
         }
     }
 
+    private ShareAcquiredRecords 
filterAbortedTransactionalAcquiredRecords(FetchPartitionData 
fetchPartitionData, FetchIsolation isolationLevel, ShareAcquiredRecords 
shareAcquiredRecords) {
+        if (isolationLevel != FetchIsolation.TXN_COMMITTED)
+            return shareAcquiredRecords;
+        // When FetchIsolation.TXN_COMMITTED is used as isolation type by the 
share group, we need to filter any
+        // transactions that were aborted/did not commit due to timeout.
+        List<AcquiredRecords> result = 
filterAbortedTransactionalRecords(fetchPartitionData.records.batches(), 
shareAcquiredRecords.acquiredRecords(), fetchPartitionData.abortedTransactions);
+        int acquiredCount = 0;
+        for (AcquiredRecords records : result) {
+            acquiredCount += (int) (records.lastOffset() - 
records.firstOffset() + 1);
+        }
+        return new ShareAcquiredRecords(result, acquiredCount);
+    }
+
+    private List<AcquiredRecords> filterAbortedTransactionalRecords(
+        Iterable<? extends RecordBatch> batches,
+        List<AcquiredRecords> acquiredRecords,
+        Optional<List<FetchResponseData.AbortedTransaction>> 
abortedTransactions

Review Comment:
   so far in the testing I have observed that the `abortedTransactions` 
contains all the first offset of all the fetched record batches that have been 
aborted in **ascending order** of the first offset.



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