Flink - 如何解决错误 This job is not stoppable

Flink - how to solve error This job is not stoppable

我试图通过 flink stop 停止作业

flink stop [jobid]

但是 CLI 抛出错误并且不允许我停止作业。我可以取消它。 这里可能是什么原因?

Stopping job c7196bb1d21d679efed73770a4e4f9ed.

------------------------------------------------------------ The program finished with the following exception:

org.apache.flink.util.FlinkException: Could not stop the job c7196bb1d21d679efed73770a4e4f9ed. at org.apache.flink.client.cli.CliFrontend.lambda$stop(CliFrontend.java:557) at org.apache.flink.client.cli.CliFrontend.runClusterAction(CliFrontend.java:988) at org.apache.flink.client.cli.CliFrontend.stop(CliFrontend.java:550) at org.apache.flink.client.cli.CliFrontend.parseParameters(CliFrontend.java:1065) at org.apache.flink.client.cli.CliFrontend.lambda$main(CliFrontend.java:1129) at org.apache.flink.runtime.security.NoOpSecurityContext.runSecured(NoOpSecurityContext.java:30) at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1129) Caused by: java.util.concurrent.ExecutionException: org.apache.flink.runtime.rest.util.RestClientException: [Job termination (STOP) failed: This job is not stoppable.] at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357) at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1915) at org.apache.flink.client.program.rest.RestClusterClient.stop(RestClusterClient.java:392) at org.apache.flink.client.cli.CliFrontend.lambda$stop(CliFrontend.java:555) ... 6 more Caused by: org.apache.flink.runtime.rest.util.RestClientException: [Job termination (STOP) failed: This job is not stoppable.] at org.apache.flink.runtime.rest.RestClient.parseResponse(RestClient.java:351) at org.apache.flink.runtime.rest.RestClient.lambda$submitRequest(RestClient.java:335) at java.util.concurrent.CompletableFuture.uniCompose(CompletableFuture.java:952) at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:926) at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:442) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

要让一个Flink作业可以停止,它的所有源都必须实现Stoppable接口,在这一点上仍然很少有人这样做。 Flink 绑定的 Source Connector 中,只有 Storm SpoutWrapper、TwitterSource 和 NifiSource 停止支持。

您似乎打算使用停止,但对于大多数用途,取消命令更为合适。与取消相比,停止的唯一可以想到的好处是您可以避免丢失或重复的结果。但是,如果您使用的是实现检查点接口的连接器,例如 Kafka 连接器,那么您如何关闭作业并不重要——无论如何您都可以实现精确一次语义。

更新:Flink 1.9 中删除了 Stoppable 接口,重新实现了 stop 命令,现在在大多数情况下优先于 cancel 命令。有关详细信息,请参阅 the documentation

我使用了cancel命令来终止flink streming作业。

>flink cancel [JobId]
>flink cancel 79045f661e3ac9b082f63726bfb61597