Shekhar Prasad Rajak created KAFKA-20739:
--------------------------------------------
Summary: Transaction coordinator rejects InitProducerId v6
recovery with KeepPreparedTxn=true
Key: KAFKA-20739
URL: https://issues.apache.org/jira/browse/KAFKA-20739
Project: Kafka
Issue Type: Bug
Components: core
Affects Versions: 4.2.1
Reporter: Shekhar Prasad Rajak
Fix For: 4.3.1
InitProducerId v6 defines KeepPreparedTxn, OngoingTxnProducerId, and
OngoingTxnProducerEpoch for 2PC recovery. Even when InitProducerId v6 is forced
directly and broker-side 2PC is enabled, the transaction
coordinator rejects keepPreparedTxn=true with UNSUPPORTED_VERSION.
Example:
InitProducerIdRequestData data = new InitProducerIdRequestData()
.setTransactionalId("txn-2pc")
.setTransactionTimeoutMs(10)
.setProducerId(RecordBatch.NO_PRODUCER_ID)
.setProducerEpoch(RecordBatch.NO_PRODUCER_EPOCH)
.setEnable2Pc(true)
.setKeepPreparedTxn(true);
InitProducerIdRequest request =
new InitProducerIdRequest.Builder(data).build((short) 6);
Current behavior:
errorCode = 35
35 is Errors.UNSUPPORTED_VERSION.
Flow:
InitProducerId v6 request
-> KafkaApis.handleInitProducerIdRequest()
-> TransactionCoordinator.handleInitProducerId()
-> keepPreparedTxn == true
-> returns Errors.UNSUPPORTED_VERSION
Expected behavior:
With broker config transaction.two.phase.commit.enable=true,
keepPreparedTxn=true should be accepted when enable2Pc=true.
If there is no ongoing 2PC transaction:
error = NONE
ongoingTxnProducerId = -1
ongoingTxnProducerEpoch = -1
If there is an ongoing 2PC transaction:
error = NONE
broker preserves the ongoing transaction
response includes ongoingTxnProducerId / ongoingTxnProducerEpoch
client enters PREPARED_TRANSACTION
completeTransaction(preparedTxnState) can finalize it
Expected broker/client state flow:
Client: READY -> IN_TRANSACTION -> PREPARED_TRANSACTION
Broker: EMPTY -> ONGOING 2PC transaction
Crash/restart
Client: initTransactions(true)
Broker: returns ongoing producer id/epoch
Client: PREPARED_TRANSACTION
Client: completeTransaction(preparedState)
Broker: PREPARE_COMMIT -> COMPLETE_COMMIT
--
This message was sent by Atlassian Jira
(v8.20.10#820010)