[ 
https://issues.apache.org/jira/browse/KAFKA-21588?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18148055#comment-18148055
 ] 

Oneby Wang commented on KAFKA-21588:
------------------------------------

On trunk {{53f279fc58}}, repetitions 7 and 9 of 10 failed at the same line with 
retries disabled. The excerpts below are from repetition 7. Repetition 9 logged 
the same epoch mismatch at 13:10:47.600 with producer ID 1000 and the same 
client stack.

*Coordinator log and stack*

The abort marker for {{topic1-0}} succeeded. When the coordinator applied the 
completion record, the record still carried epoch 1, but the [test 
helper|https://github.com/apache/kafka/blob/53f279fc5882c8644fbf378fea8929852348da6c/storage/src/test/java/org/apache/kafka/tiered/storage/integration/TransactionsTestHelper.java#L698-L703]
 had already set the in-memory epoch to 32765.

{noformat}
[13:09:43.289] ERROR 
org.apache.kafka.coordinator.transaction.TransactionMetadata 
TransactionMetadata(transactionalId=test-overflow, producerId=1, 
prevProducerId=1, nextProducerId=-1, producerEpoch=32765, lastProducerEpoch=0, 
nextProducerEpoch=-1, txnTimeoutMs=500, state=PREPARE_ABORT, 
pendingState=Optional[COMPLETE_ABORT], topicPartitions=[], 
txnStartTimestamp=1795151383226, txnLastUpdateTimestamp=1795151383238, 
clientTransactionVersion=TV_2)'s transition to TxnTransitMetadata[producerId=1, 
prevProducerId=1, nextProducerId=-1, producerEpoch=1, lastProducerEpoch=0, 
nextProducerEpoch=-1, txnTimeoutMs=500, txnState=COMPLETE_ABORT, 
topicPartitions=[], txnStartTimestamp=1795151383226, 
txnLastUpdateTimestamp=1795151383238, clientTransactionVersion=TV_2] failed: 
this should not happen
[13:09:43.290] ERROR kafka.cluster.DelayedOperations Exception while executing 
the action
java.lang.IllegalStateException: TransactionalId test-overflow failed 
transition to state TxnTransitMetadata[producerId=1, prevProducerId=1, 
nextProducerId=-1, producerEpoch=1, lastProducerEpoch=0, nextProducerEpoch=-1, 
txnTimeoutMs=500, txnState=COMPLETE_ABORT, topicPartitions=[], 
txnStartTimestamp=1795151383226, txnLastUpdateTimestamp=1795151383238, 
clientTransactionVersion=TV_2] due to unexpected metadata
        at 
org.apache.kafka.coordinator.transaction.TransactionMetadata.throwStateTransitionFailure(TransactionMetadata.java:628)
        at 
org.apache.kafka.coordinator.transaction.TransactionMetadata.completeTransitionTo(TransactionMetadata.java:525)
        at 
kafka.coordinator.transaction.TransactionStateManager.$anonfun$appendTransactionToLog$3(TransactionStateManager.scala:820)
        at 
kafka.coordinator.transaction.TransactionStateManager.$anonfun$appendTransactionToLog$3$adapted(TransactionStateManager.scala:811)
        at 
org.apache.kafka.coordinator.transaction.TransactionMetadata.inLock(TransactionMetadata.java:151)
        at 
kafka.coordinator.transaction.TransactionStateManager.updateCacheCallback$1(TransactionStateManager.scala:811)
{noformat}

*JUnit timeout and producer stack*

The second producer kept retrying {{InitProducerId}} while completion was 
pending. JUnit interrupted it at the 60-second test timeout, before the 
rollover assertion.

{noformat}
java.util.concurrent.TimeoutException: 
testRecoveryFromEpochOverflow(org.apache.kafka.common.test.ClusterInstance) 
timed out after 60 seconds
    ...
        Suppressed: org.apache.kafka.common.errors.InterruptException: Received 
interrupt while awaiting InitProducerId
                at 
org.apache.kafka.clients.producer.internals.TransactionalRequestResult.await(TransactionalRequestResult.java:63)
                at 
org.apache.kafka.clients.producer.KafkaProducer.initTransactions(KafkaProducer.java:742)
                at 
org.apache.kafka.clients.producer.Producer.initTransactions(Producer.java:48)
                at 
org.apache.kafka.tiered.storage.integration.TransactionsTestHelper.testRecoveryFromEpochOverflow(TransactionsTestHelper.java:708)
                at 
org.apache.kafka.tiered.storage.integration.TransactionsWithTieredStoreTest.testRecoveryFromEpochOverflow(TransactionsWithTieredStoreTest.java:250)
{noformat}

> Flaky test TransactionsWithTieredStoreTest#testRecoveryFromEpochOverflow
> ------------------------------------------------------------------------
>
>                 Key: KAFKA-21588
>                 URL: https://issues.apache.org/jira/browse/KAFKA-21588
>             Project: Kafka
>          Issue Type: Test
>            Reporter: Oneby Wang
>            Assignee: Oneby Wang
>            Priority: Minor
>              Labels: flaky-test
>
> TransactionsWithTieredStoreTest#testRecoveryFromEpochOverflow intermittently 
> times out in the second producer's initTransactions(), before the test 
> reaches its epoch rollover assertion.
> On trunk revision 53f279fc5882c8644fbf378fea8929852348da6c (macOS, Temurin 
> 25.0.4, Gradle 9.8.2), repetitions 7 and 9 of 10 failed with retries disabled.
> {code:bash}
> ./gradlew :storage:test --rerun --no-parallel --max-workers=3 \
>   -PmaxParallelForks=1 -PmaxTestRetries=0 -Pkafka.cluster.test.repeat=10 \
>   --tests 
> org.apache.kafka.tiered.storage.integration.TransactionsWithTieredStoreTest.testRecoveryFromEpochOverflow
> {code}
> In both failures, the helper had set the producer epoch to 32765 while the 
> coordinator was still in PREPARE_ABORT with COMPLETE_ABORT pending. The 
> completion callback carried epoch 1 and threw IllegalStateException. The 
> second producer kept retrying InitProducerId until the test timed out after 
> 60 seconds.
> The first abort should complete before the helper sets the boundary epoch. A 
> test-only change waits for COMPLETE_ABORT with no pending transition, then 
> sets the epoch under the same metadata lock. With the original asynchronous 
> send, the tiered and non-tiered tests each passed 10/10 locally. In a 
> separate run with a 750 ms pause before appending the first COMPLETE_ABORT, 
> the original test reproduced the same failure and the changed test passed.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to