我在本地运行一个应用程序(Spring Boot和Spring Cloud Stream和Kafka Binder和Kafka Streams Binder),该应用程序消耗并产生多个主题,这些主题全部具有4个分区。我在使用KafkaStreams时有一些状态流处理。在多个实例中启动该应用程序后,一切似乎都很好,但是一个实例崩溃的那一刻,其他实例不断不断抛出FileNotFoundException。
运行3个实例时,刚启动后我会看到:
current active tasks: [0_0, 1_0]
current standby tasks: []
previous active tasks: [0_0, 1_0, 0_1, 1_1]
current active tasks: [0_2, 1_2, 0_3]
current standby tasks: []
previous active tasks: [0_2, 1_2, 0_3, 1_3]
current active tasks: [0_1, 1_1, 1_3]
current standby tasks: []
previous active tasks: []
我向kafka流处理的主题发布了一些消息,并且一切正常。但是当我关闭第一个实例时,第二个实例会连续抛出
java.io.FileNotFoundException: /tmp/kafka-streams/my-service/1_2/.checkpoint.tmp (No such file or directory)
at java.io.FileOutputStream.open0(Native Method) ~[na:1.8.0_144]
at java.io.FileOutputStream.open(FileOutputStream.java:270) ~[na:1.8.0_144]
at java.io.FileOutputStream.<init>(FileOutputStream.java:213) ~[na:1.8.0_144]
at java.io.FileOutputStream.<init>(FileOutputStream.java:162) ~[na:1.8.0_144]
at org.apache.kafka.streams.state.internals.OffsetCheckpoint.write(OffsetCheckpoint.java:78) ~[kafka-streams-2.0.1.jar:na]
at org.apache.kafka.streams.processor.internals.ProcessorStateManager.checkpoint(ProcessorStateManager.java:315) ~[kafka-streams-2.0.1.jar:na]
at org.apache.kafka.streams.processor.internals.StreamTask.commit(StreamTask.java:397) [kafka-streams-2.0.1.jar:na]
at org.apache.kafka.streams.processor.internals.StreamTask.commit(StreamTask.java:382) [kafka-streams-2.0.1.jar:na]
at org.apache.kafka.streams.processor.internals.AssignedTasks$1.apply(AssignedTasks.java:67) [kafka-streams-2.0.1.jar:na]
at org.apache.kafka.streams.processor.internals.AssignedTasks.applyToRunningTasks(AssignedTasks.java:362) [kafka-streams-2.0.1.jar:na]
at org.apache.kafka.streams.processor.internals.AssignedTasks.commit(AssignedTasks.java:352) [kafka-streams-2.0.1.jar:na]
at org.apache.kafka.streams.processor.internals.TaskManager.commitAll(TaskManager.java:401) [kafka-streams-2.0.1.jar:na]
at org.apache.kafka.streams.processor.internals.StreamThread.maybeCommit(StreamThread.java:1042) [kafka-streams-2.0.1.jar:na]
at org.apache.kafka.streams.processor.internals.StreamThread.runOnce(StreamThread.java:845) [kafka-streams-2.0.1.jar:na]
at org.apache.kafka.streams.processor.internals.StreamThread.runLoop(StreamThread.java:767) [kafka-streams-2.0.1.jar:na]
at org.apache.kafka.streams.processor.internals.StreamThread.run(StreamThread.java:736) [kafka-streams-2.0.1.jar:na]
和第三个相同,只是目录一次:
/ tmp / kafka-streams / my-service / 1_1 /。checkpoint.tmp
然后一次:
/ tmp / kafka-streams / my-service / 1_3 /。checkpoint.tmp
在tmp / kafka-streams / my-service中,我看到实际上在关闭第一个实例后仅目录0_0 0_1 0_2 0_3 1_0保持存在。
它不会使应用程序崩溃,并且从我所看到的状态可以从正在运行的实例中访问(但是我可能在这里丢失了一些东西)。有谁知道抛出此异常的原因,它可能产生的影响以及我应该对其进行更改以解决此问题?