cheeeee commented on code in PR #24072:
URL: https://github.com/apache/kafka/pull/24072#discussion_r4462477104


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/Cleaner.java:
##########
@@ -728,7 +728,13 @@ public void buildOffsetMap(UnifiedLog log,
         logger.info("Building offset map for log {} for {} segments in offset 
range [{}, {}).", log.name(), dirty.size(), start, end);
 
         CleanedTransactionMetadata transactionMetadata = new 
CleanedTransactionMetadata();
-        List<AbortedTxn> abortedTransactions = 
log.collectAbortedTransactions(start, end);
+        // collectAbortedTransactions uses the log start offset, not start, as 
its lower bound, so it also returns
+        // aborted transactions that ended before start. This pass may not 
read their ABORT markers (reading begins at
+        // the offset index entry at or below start), and seeding them would 
make every later transactional batch of
+        // those producers, including committed ones, count as aborted and 
leave its keys out of the offset map.
+        List<AbortedTxn> abortedTransactions = 
log.collectAbortedTransactions(start, end).stream()

Review Comment:
   Yes, that's simpler. 
   
   Done in 03d0e80fa7: `LocalLog.collectAbortedTransactions` no longer takes 
`logStartOffset` and uses `startOffset` both to locate the starting segment and 
as the lower bound. 
   
   The only caller to update was `UnifiedLog.collectAbortedTransactions`, whose 
signature stays the same, and the filter in `buildOffsetMap` is gone.
   
   This also makes `cleanSegments` consistent for a segment that starts below 
the log start offset. Aborted transactions whose ABORT marker is below the log 
start offset used to be skipped there, so their data
   was kept as if committed and their index entries were dropped; now they are 
collected like the rest of the segment, so the data is removed and the entries 
are kept. For every other segment the result is the
   same, since `cleanSegments` passes the segment base offset and an aborted 
transaction is indexed in the segment that holds its ABORT marker. All of this 
is below the log start offset, so fetches see no
   difference. I guess this is what I missed in the first place. 



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