从保存点检索到无效状态

时间:2019-09-13 16:19:40

标签: apache-flink flink-streaming

最近,我开始遇到在Flink应用程序中加载保存点的问题。当我执行RabbitMQ源代码时,抛出以下异常

java.lang.IllegalArgumentException: $anon$1 retrieved invalid state.
    at org.apache.flink.util.Preconditions.checkArgument(Preconditions.java:139)
    at org.apache.flink.streaming.api.functions.source.MessageAcknowledgingSourceBase.initializeState(MessageAcknowledgingSourceBase.java:158)
    at org.apache.flink.streaming.util.functions.StreamingFunctionUtils.tryRestoreFunction(StreamingFunctionUtils.java:178)
    at org.apache.flink.streaming.util.functions.StreamingFunctionUtils.restoreFunctionState(StreamingFunctionUtils.java:160)
    at org.apache.flink.streaming.api.operators.AbstractUdfStreamOperator.initializeState(AbstractUdfStreamOperator.java:96)
    at org.apache.flink.streaming.api.operators.AbstractStreamOperator.initializeState(AbstractStreamOperator.java:278)
    at org.apache.flink.streaming.runtime.tasks.StreamTask.initializeState(StreamTask.java:738)
    at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:289)
    at org.apache.flink.runtime.taskmanager.Task.run(Task.java:711)
    at java.lang.Thread.run(Thread.java:748)

按照Flink中的代码,我看到以下代码段

    public void initializeState(FunctionInitializationContext context) throws Exception {
        Preconditions.checkState(this.checkpointedState == null, "The " + this.getClass().getSimpleName() + " has already been initialized.");
        this.checkpointedState = context.getOperatorStateStore().getSerializableListState("message-acknowledging-source-state");
        this.idsForCurrentCheckpoint = new HashSet(64);
        this.pendingCheckpoints = new ArrayDeque();
        this.idsProcessedButNotAcknowledged = new HashSet();
        if (context.isRestored()) {
            LOG.info("Restoring state for the {}.", this.getClass().getSimpleName());
            List<SerializedCheckpointData[]> retrievedStates = new ArrayList();
            Iterator var3 = ((Iterable)this.checkpointedState.get()).iterator();

            while(var3.hasNext()) {
                SerializedCheckpointData[] entry = (SerializedCheckpointData[])var3.next();
                retrievedStates.add(entry);
            }

            Preconditions.checkArgument(retrievedStates.size() == 1, this.getClass().getSimpleName() + " retrieved invalid state.");
            this.pendingCheckpoints = SerializedCheckpointData.toDeque((SerializedCheckpointData[])retrievedStates.get(0), this.idSerializer);
            var3 = this.pendingCheckpoints.iterator();

            while(var3.hasNext()) {
                Tuple2<Long, Set<UId>> checkpoint = (Tuple2)var3.next();
                this.idsProcessedButNotAcknowledged.addAll((Collection)checkpoint.f1);
            }
        } else {
            LOG.info("No state to restore for the {}.", this.getClass().getSimpleName());
        }

    }
  

Preconditions.checkArgument(retrievedStates.size()== 1,this.getClass()。getSimpleName()+“检索到无效状态。”);

似乎是引发错误的行。但是我不清楚该州的无效之处是什么,或者我可以采取什么措施对此进行补救。

供参考的保存点后端是S3,正在运行的Flink版本是1.8.2。另外,我为RabbitMQ连接器设置了.uid

0 个答案:

没有答案