artemlivshits commented on code in PR #20882:
URL: https://github.com/apache/kafka/pull/20882#discussion_r2535643854


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/ProducerAppendInfo.java:
##########
@@ -250,7 +243,21 @@ public Optional<CompletedTxn> 
appendEndTxnMarker(EndTransactionMarker endTxnMark
                                                      long offset,
                                                      long timestamp,
                                                      short transactionVersion) 
{
-        checkProducerEpoch(producerEpoch, offset, transactionVersion);
+        // For replication (REPLICATION origin), TV_UNKNOWN is allowed because:
+        // 1. transactionVersion is not stored in MemoryRecords - it's only 
metadata in WriteTxnMarkersRequest
+        // 2. When records are replicated, followers only see MemoryRecords 
without transactionVersion
+        // 3. The leader already validated the marker with the correct 
transactionVersion (e.g., TV2 strict validation)
+        // 4. Using TV_0 validation (markerEpoch >= currentEpoch) is safe 
because it's more permissive than TV2
+        //    (markerEpoch > currentEpoch), so any marker that passed TV2 
validation will pass TV_0 validation
+        // For all other origins (CLIENT, COORDINATOR), transactionVersion 
must be explicitly specified.
+        if (transactionVersion == TV_UNKNOWN && origin != 
AppendOrigin.REPLICATION) {
+            throw new IllegalArgumentException("transactionVersion must be 
explicitly specified (TV_0, TV_1, or TV_2), " +

Review Comment:
   The error message will become misleading if we add TV_3.  We should just say 
TV_0 or above.



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