Hi all, I'm currently facing an issue with Flink w...
# troubleshooting
d
Hi all, I'm currently facing an issue with Flink when trying to use exactly-once semantics with Kafka. It seems that my producer unable to commit a transaction. In the error log I always see the same transactionId.
Copy code
2023-12-21 13:29:16,276 INFO  org.apache.kafka.clients.producer.internals.TransactionManager [] - [Producer clientId=producer-esp.999.5m.host-header-0-405249, transactionalId=esp.999.5m.host-header-0-405249] Discovered transaction coordinator 10.50.0.10:9093 (id: 1002 rack: null)
 2023-12-21 13:29:16,452 INFO  org.apache.kafka.clients.producer.internals.TransactionManager [] - [Producer clientId=producer-esp.999.5m.host-header-0-405249, transactionalId=esp.999.5m.host-header-0-405249] Transiting to fatal error state due to org.apache.kafka.common.errors.InvalidTxnStateException: The producer attempted a transactional operation in an invalid state.
 2023-12-21 13:29:16,452 ERROR org.apache.flink.connector.kafka.sink.KafkaCommitter         [] - Unable to commit transaction (org.apache.flink.streaming.runtime.operators.sink.committables.CommitRequestImpl@4a951916) because it's in an invalid state. Most likely the transaction has been aborted for some reason. Please check the Kafka logs for more details.
 org.apache.kafka.common.errors.InvalidTxnStateException: The producer attempted a transactional operation in an invalid state.
I've ensured unique "transactional.id", checked configurations, and also checked the Kafka logs, but I didn't find this specific transactionId. Any insights or suggestions on how to troubleshoot further would be appreciated.
y
Can you set flink Kafka connector and the Kafka producer with DEBUG logs? Might give some more information on what's going on.
d
Hi @Yuval Itzchakov, I appreciate your willingness to assist. Here are the DEBUG logs.
Copy code
2023-12-24 15:06:05,263 DEBUG org.apache.kafka.clients.producer.internals.Sender           [] - [Producer clientId=producer-esp.999.5m.host-header-0-430726, transactionalId=esp.999.5m.host-header-0-430726] Sending transactional request EndTxnRequestData(transactionalId='esp.999.5m.host-header-0-430726', producerId=3681623, producerEpoch=0, committed=true) to node 10.80.0.7:9093 (id: 1003 rack: null) with correlation ID 4

2023-12-24 15:06:05,263 DEBUG org.apache.kafka.clients.NetworkClient                       [] - [Producer clientId=producer-esp.999.5m.host-header-0-430726, transactionalId=esp.999.5m.host-header-0-430726] Sending END_TXN request with header RequestHeader(apiKey=END_TXN, apiVersion=3, clientId=producer-esp.999.5m.host-header-0-430726, correlationId=4) and timeout 30000 to node 1003: EndTxnRequestData(transactionalId='esp.999.5m.host-header-0-430726', producerId=3681623, producerEpoch=0, committed=true)

2023-12-24 15:06:05,265 DEBUG org.apache.kafka.clients.NetworkClient                       [] - [Producer clientId=producer-esp.999.5m.host-header-0-430726, transactionalId=esp.999.5m.host-header-0-430726] Received END_TXN response from node 1003 for request with header RequestHeader(apiKey=END_TXN, apiVersion=3, clientId=producer-esp.999.5m.host-header-0-430726, correlationId=4): EndTxnResponseData(throttleTimeMs=0, errorCode=48)

2023-12-24 15:06:05,265 INFO  org.apache.kafka.clients.producer.internals.TransactionManager [] - [Producer clientId=producer-esp.999.5m.host-header-0-430726, transactionalId=esp.999.5m.host-header-0-430726] Transiting to fatal error state due to org.apache.kafka.common.errors.InvalidTxnStateException: The producer attempted a transactional operation in an invalid state.

2023-12-24 15:06:05,265 DEBUG org.apache.kafka.clients.producer.internals.TransactionManager [] - [Producer clientId=producer-esp.999.5m.host-header-0-430726, transactionalId=esp.999.5m.host-header-0-430726] Transition from state COMMITTING_TRANSACTION to error state FATAL_ERROR
org.apache.kafka.common.errors.InvalidTxnStateException: The producer attempted a transactional operation in an invalid state.

2023-12-24 15:06:05,265 ERROR org.apache.flink.connector.kafka.sink.KafkaCommitter         [] - Unable to commit transaction (org.apache.flink.streaming.runtime.operators.sink.committables.CommitRequestImpl@63dd25e3) because it's in an invalid state. Most likely the transaction has been aborted for some reason. Please check the Kafka logs for more details.
org.apache.kafka.common.errors.InvalidTxnStateException: The producer attempted a transactional operation in an invalid state.
I didn't find anything interesting. What do you think?
y
Looks like we need to look at the Kafka brokers to understand what’s the real underlying issue