Apache Flink:注册名称冲突。名称为***的KvState已由其他运营商注册

时间:2018-04-24 12:28:02

标签: apache-flink flink-streaming

我在执行flink工作时遇到了这个问题。

Registration name clash. KvState with name 'XXXX' has already been registered by another operator (fab4c54085fa3ee85a6e1bb1062c20af).

例外:

org.apache.flink.runtime.execution.SuppressRestartsException: Unrecoverable failure. This suppresses job restarts. Please check the stack trace for the root cause.
    at org.apache.flink.runtime.query.KvStateLocationRegistry.notifyKvStateRegistered(KvStateLocationRegistry.java:120)
    at org.apache.flink.runtime.jobmanager.JobManager.org$apache$flink$runtime$jobmanager$JobManager$$handleKvStateMessage(JobManager.scala:1517)
    at org.apache.flink.runtime.jobmanager.JobManager$$anonfun$handleMessage$1.applyOrElse(JobManager.scala:740)
    at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36)
    at org.apache.flink.runtime.LeaderSessionMessageFilter$$anonfun$receive$1.applyOrElse(LeaderSessionMessageFilter.scala:49)
    at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36)
    at org.apache.flink.runtime.LogMessages$$anon$1.apply(LogMessages.scala:33)
    at org.apache.flink.runtime.LogMessages$$anon$1.apply(LogMessages.scala:28)
    at scala.PartialFunction$class.applyOrElse(PartialFunction.scala:123)
    at org.apache.flink.runtime.LogMessages$$anon$1.applyOrElse(LogMessages.scala:28)
    at akka.actor.Actor$class.aroundReceive(Actor.scala:502)
    at org.apache.flink.runtime.jobmanager.JobManager.aroundReceive(JobManager.scala:122)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)
    at akka.actor.ActorCell.invoke(ActorCell.scala:495)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
    at akka.dispatch.Mailbox.run(Mailbox.scala:224)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.lang.IllegalStateException: Registration name clash. KvState with name 'XXXX' has already been registered by another operator (fab4c54085fa3ee85a6e1bb1062c20af).
    at org.apache.flink.runtime.query.KvStateLocationRegistry.notifyKvStateRegistered(KvStateLocationRegistry.java:116)
    ... 20 more

当我从IntelliJ IDE运行作业时,它运行良好,但是当我使用以下命令运行作业时,我遇到了这个问题。

  

bin / flink run -c com.xxx.XXXJob

出现此错误的原因是什么? 我已经重新启动flink并重新运行该作业,但我仍然遇到此错误。

1 个答案:

答案 0 :(得分:1)

我在两个流程函数中配置了可查询状态的相同名称。

    @Override
    public void open(Configuration parameters) {
        ValueStateDescriptor<? super Output> descriptor = new ValueStateDescriptor(queryableStateName, Xyz.class);
        descriptor.setQueryable("downloads");
        state = getRuntimeContext().getState(descriptor);
    }

在上面的代码descriptor.setQueryable("downloads");中,我在多个流程函数中给了downloads

关于我从IDE而不是bin/flink run命令运行的原因令人惊讶。

原因是'flink-queryable-state-runtime_2.11-1.4.2.jar'

当我从IDE运行时,IDE无法从类路径中找到此jar。因此,可查询功能被禁用,并且由于该工作从不抱怨。所以工作成功。

但是当我使用bin/flink run时,它会从flink的lib中找到。

因此,由于名称相同而导致错误,作业失败。