You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
KAFKA-19690 Add epoch check before verification guard check to prevent unexpected fatal error (#20607)
Cherry-pick changes (#20534) to 4.0
Conflicts:
->
storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java
- kept the file the same, and the rest of the code is in
UnifiedLog.scala in 4.0 so added it there
-> core/src/test/scala/unit/kafka/log/UnifiedLogTest.scala - just added
the required test and kept everything else the same
Reviewers: Justine Olshan
[[email protected]](mailto:[email protected]), Chia-Ping Tsai
[[email protected]](mailto:[email protected])
Copy file name to clipboardExpand all lines: core/src/main/scala/kafka/log/UnifiedLog.scala
+11-2Lines changed: 11 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1057,8 +1057,17 @@ class UnifiedLog(@volatile var logStartOffset: Long,
1057
1057
// transaction is completed or aborted. We can guarantee the transaction coordinator knows about the transaction given step 1 and that the transaction is still
1058
1058
// ongoing. If the transaction is expected to be ongoing, we will not set a VerificationGuard. If the transaction is aborted, hasOngoingTransaction is false and
1059
1059
// requestVerificationGuard is the sentinel, so we will throw an error. A subsequent produce request (retry) should create verification state and return to phase 1.
1060
-
if (batch.isTransactional &&!hasOngoingTransaction(batch.producerId, batch.producerEpoch()) && batchMissingRequiredVerification(batch, requestVerificationGuard))
1061
-
thrownewInvalidTxnStateException("Record was not part of an ongoing transaction")
1060
+
if (batch.isTransactional &&!hasOngoingTransaction(batch.producerId, batch.producerEpoch)) {
1061
+
// Check epoch first: if producer epoch is stale, throw recoverable InvalidProducerEpochException.
0 commit comments