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 (apache#20577)
Cherry-pick changes (apache#20534) to 3.9
Conflicts:
->
storage/src/main/java/org/apache/kafka/storage/internals/log/UnifiedLog.java
- it is UnifiedLog.scala in 3.9
-> core/src/test/scala/unit/kafka/log/UnifiedLogTest.scala - had more
changes than the 3.9 version, just added the test and kept everything
else the same
Reviewers: Justine Olshan <[email protected]>, Chia-Ping Tsai
<[email protected]>
Copy file name to clipboardExpand all lines: core/src/main/scala/kafka/log/UnifiedLog.scala
+13-2Lines changed: 13 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1067,8 +1067,19 @@ class UnifiedLog(@volatile var logStartOffset: Long,
1067
1067
// transaction is completed or aborted. We can guarantee the transaction coordinator knows about the transaction given step 1 and that the transaction is still
1068
1068
// ongoing. If the transaction is expected to be ongoing, we will not set a VerificationGuard. If the transaction is aborted, hasOngoingTransaction is false and
1069
1069
// requestVerificationGuard is the sentinel, so we will throw an error. A subsequent produce request (retry) should create verification state and return to phase 1.
1070
-
if (batch.isTransactional &&!hasOngoingTransaction(batch.producerId) && batchMissingRequiredVerification(batch, requestVerificationGuard))
1071
-
thrownewInvalidTxnStateException("Record was not part of an ongoing transaction")
1070
+
if (batch.isTransactional &&!hasOngoingTransaction(batch.producerId)) {
1071
+
// Check epoch first: if producer epoch is stale, throw recoverable InvalidProducerEpochException.
0 commit comments