Hey all! I’ve recently migrated an old job running...
# troubleshooting
r
Hey all! I’ve recently migrated an old job running on Flink 1.15 to Flink 1.18 (on the operator). I stopped the old job with a savepoint and am using that same savepoint for the
initialSavepointPath
to restore the job on the operator. The handoff seems fine at first but it looks like when it begins processing data from Kafka (or the savepoint itself) that the APIs have shifted or are incompatible with the following error:
Copy code
2024-03-13 16:45:45,938 ERROR org.apache.flink.connector.kafka.sink.KafkaCommitter         [] - Transaction (org.apache.flink.streaming.runtime.operators.sink.committables.CommitRequestImpl@24ef5b52) encountered error and data has been potentially lost.
java.lang.RuntimeException: Incompatible KafkaProducer version
	at org.apache.flink.connector.kafka.sink.FlinkKafkaInternalProducer.getField(FlinkKafkaInternalProducer.java:285) ~[blob_p-d8bf403a8a51c95305f1ab59a0ff39a6467603a6-afd009f29d87580cf4db55ed4d073f62:?]
	at org.apache.flink.connector.kafka.sink.FlinkKafkaInternalProducer.getField(FlinkKafkaInternalProducer.java:272) ~[blob_p-d8bf403a8a51c95305f1ab59a0ff39a6467603a6-afd009f29d87580cf4db55ed4d073f62:?]
	at org.apache.flink.connector.kafka.sink.FlinkKafkaInternalProducer.resumeTransaction(FlinkKafkaInternalProducer.java:310) ~[blob_p-d8bf403a8a51c95305f1ab59a0ff39a6467603a6-afd009f29d87580cf4db55ed4d073f62:?]
	at org.apache.flink.connector.kafka.sink.KafkaCommitter.getRecoveryProducer(KafkaCommitter.java:143) ~[blob_p-d8bf403a8a51c95305f1ab59a0ff39a6467603a6-afd009f29d87580cf4db55ed4d073f62:?]
	at org.apache.flink.connector.kafka.sink.KafkaCommitter.lambda$commit$0(KafkaCommitter.java:72) ~[blob_p-d8bf403a8a51c95305f1ab59a0ff39a6467603a6-afd009f29d87580cf4db55ed4d073f62:?]
	at java.util.Optional.orElseGet(Unknown Source) ~[?:?]
	at org.apache.flink.connector.kafka.sink.KafkaCommitter.commit(KafkaCommitter.java:72) ~[blob_p-d8bf403a8a51c95305f1ab59a0ff39a6467603a6-afd009f29d87580cf4db55ed4d073f62:?]
	at org.apache.flink.streaming.runtime.operators.sink.committables.CheckpointCommittableManagerImpl.commit(CheckpointCommittableManagerImpl.java:126) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.runtime.operators.sink.CommitterOperator.commitAndEmit(CommitterOperator.java:176) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.runtime.operators.sink.CommitterOperator.commitAndEmitCheckpoints(CommitterOperator.java:160) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.runtime.operators.sink.CommitterOperator.initializeState(CommitterOperator.java:121) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.api.operators.StreamOperatorStateHandler.initializeOperatorState(StreamOperatorStateHandler.java:122) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.api.operators.AbstractStreamOperator.initializeState(AbstractStreamOperator.java:274) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.runtime.tasks.RegularOperatorChain.initializeStateAndOpenOperators(RegularOperatorChain.java:106) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreGates(StreamTask.java:753) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.call(StreamTaskActionExecutor.java:55) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreInternal(StreamTask.java:728) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restore(StreamTask.java:693) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:953) [flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:922) [flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:746) [flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.runtime.taskmanager.Task.run(Task.java:562) [flink-dist-1.18.1.jar:1.18.1]
	at java.lang.Thread.run(Unknown Source) [?:?]
Caused by: java.lang.NoSuchFieldException: txnPartitionMap
	at java.lang.Class.getDeclaredField(Unknown Source) ~[?:?]
	at org.apache.flink.connector.kafka.sink.FlinkKafkaInternalProducer.getField(FlinkKafkaInternalProducer.java:281) ~[blob_p-d8bf403a8a51c95305f1ab59a0ff39a6467603a6-afd009f29d87580cf4db55ed4d073f62:?]
	... 22 more
The APIs being used did not change (
KafkaSink
) and the versions should align with the appropriate version of Flink, that is:
Copy code
kafka-clients:3.2.3
flink-connector-kafka:3.1.0-1.18
Aside from those changes, no other adjustments were made to the job or calls related to Kafka usage. Any ideas?
I attempted to update the job to use
allowNonRestoredState: false
and started getting these errors now:
Copy code
2024-03-13 13:39:22
java.lang.IllegalStateException: The library registration references a different set of library BLOBs than previous registrations for this job:
old:[p-d8bf403a8a51c95305f1ab59a0ff39a6467603a6-89eb2fc54ae8fd0a94e101e5e4473d8b]
I suspect that’s a red-herring, but it certainly seems like an incompatibility issue with the previous client that generated the transactions and the updated client.
g
the allowNonRestoredState trick will work if you change the sink uid
but you will lose the state in that case
r
Yeah, that wouldn’t be ideal. I’m not sure in this case what exactly is going on. As far as I can tell all of the dependencies seem to be correct. I came across this JIRA which suggested not using 3.3.x or above, however in this case I was experiencing the same problem with 3.2.3.
It’s worth noting when I downgraded the job to Flink 17, it was able to run as expected using those dependencies so it appears to be a breaking change in Flink 18.
g
Try using the 1.17 connector with 1.18 and see what happens
r
Okay, I’ll give that a try as well and report back.
It looks like with using the Flink 17 Kafka bits, i.e:
Copy code
<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka-clients</artifactId>
    <version>3.2.3</version>
</dependency>
<dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-connector-kafka</artifactId>
    <version>3.1.0-1.17</version>
</dependency>
But targeting Flink 1.18.1 (and the appropriate image), it still fails with the expected transaction issue which makes no sense as everything worked when targeting the 1.17 image…
I finally got to the root of this. It turns out the version(s) of the connectors that I was using both (in their source code) were expecting a 3.3.x or greater version of the client. Due to the issue in this JIRA which required 3.2.x or earlier, this was failing. Eventually I targeted the 3.0.1-1.18 version of the connector which aligns/uses the 3.2.3 client that I was using previously:
Copy code
<dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-connector-kafka</artifactId>
    <version>3.0.1-1.18</version>
</dependency>
I’d be nice if there was some universally maintained chart that matched up specific clients to their appropriate connector versions somewhere. It may exist but I think that’d be incredibly useful. Something like:
Copy code
connector             | version    | client   |
-----------------------------------------------
flink-connector-kafka | 3.0.1-1.18 | 3.2.3    |
Regardless - this resolved the issue.
🎉 1