Hi All Any help is much appreciated! I have a run...
# troubleshooting
s
Hi All Any help is much appreciated! I have a running flink streaming job(flink 1.14.2) with code build say v1.0 i have enabled rocksdb checkpoints (stored in path /a/b/c) now i deployed new code/build(say v2.0); resumed from save point (provided previous checkpoint (/a/b/c ) ) while running job(new build), it instantly fails: getting below 2 errors: error1:
Copy code
java.lang.Exception: Exception while creating StreamOperatorStateContext.
	at org.apache.flink.streaming.api.operators.StreamTaskStateInitializerImpl.streamOperatorStateContext(StreamTaskStateInitializerImpl.java:255)
	at org.apache.flink.streaming.api.operators.AbstractStreamOperator.initializeState(AbstractStreamOperator.java:268)
	at org.apache.flink.streaming.runtime.tasks.RegularOperatorChain.initializeStateAndOpenOperators(RegularOperatorChain.java:109)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreGates(StreamTask.java:711)
	at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.call(StreamTaskActionExecutor.java:55)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreInternal(StreamTask.java:687)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restore(StreamTask.java:654)
	at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:958)
	at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:927)
	at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:766)
	at org.apache.flink.runtime.taskmanager.Task.run(Task.java:575)
	at java.lang.Thread.run(Thread.java:750)
Caused by: org.apache.flink.util.FlinkException: Could not restore keyed state backend for WindowOperator_b8ed87ec52186e4019237c5042653f75_(46/75) from any of the 1 provided restore options.
	at org.apache.flink.streaming.api.operators.BackendRestorerProcedure.createAndRestore(BackendRestorerProcedure.java:160)
	at org.apache.flink.streaming.api.operators.StreamTaskStateInitializerImpl.keyedStatedBackend(StreamTaskStateInitializerImpl.java:346)
	at org.apache.flink.streaming.api.operators.StreamTaskStateInitializerImpl.streamOperatorStateContext(StreamTaskStateInitializerImpl.java:164)
	... 11 more
Caused by: org.apache.flink.runtime.state.BackendBuildingException: Caught unexpected exception.
	at org.apache.flink.contrib.streaming.state.RocksDBKeyedStateBackendBuilder.build(RocksDBKeyedStateBackendBuilder.java:394)
	at org.apache.flink.contrib.streaming.state.EmbeddedRocksDBStateBackend.createKeyedStateBackend(EmbeddedRocksDBStateBackend.java:462)
	at org.apache.flink.contrib.streaming.state.EmbeddedRocksDBStateBackend.createKeyedStateBackend(EmbeddedRocksDBStateBackend.java:93)
	at org.apache.flink.streaming.api.operators.StreamTaskStateInitializerImpl.lambda$keyedStatedBackend$1(StreamTaskStateInitializerImpl.java:329)
	at org.apache.flink.streaming.api.operators.BackendRestorerProcedure.attemptCreateAndRestore(BackendRestorerProcedure.java:168)
	at org.apache.flink.streaming.api.operators.BackendRestorerProcedure.createAndRestore(BackendRestorerProcedure.java:135)
	... 13 more
Caused by: java.io.FileNotFoundException: File does not exist: /QA/rocksdb-checkpoints/social-messaging-anf/55961d5dbbc7261195e09d341420aac6/shared/1f131982-d77d-43c6-ae91-d518737f6e42
	at org.ap
error2:
Copy code
com.esotericsoftware.kryo.KryoException: java.lang.IndexOutOfBoundsException: Index: 1472, Size: 2
Serialization trace:
productId (com.rr.product.events.model.UserByProductAttribution)
	at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125)
	at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:528)
	at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:761)
	at org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer.deserialize(KryoSerializer.java:354)
	at org.apache.flink.contrib.streaming.state.AbstractRocksDBAppendingState.getInternal(AbstractRocksDBAppendingState.java:64)
	at org.apache.flink.contrib.streaming.state.RocksDBReducingState.add(RocksDBReducingState.java:94)
	at org.apache.flink.streaming.runtime.operators.windowing.WindowOperator.processElement(WindowOperator.java:413)
	at org.apache.flink.streaming.runtime.tasks.OneInputStreamTask$StreamTaskNetworkOutput.emitRecord(OneInputStreamTask.java:233)
	at org.apache.flink.streaming.runtime.io.AbstractStreamTaskNetworkInput.processElement(AbstractStreamTaskNetworkInput.java:134)
	at org.apache.flink.streaming.runtime.io.AbstractStreamTaskNetworkInput.emitNext(AbstractStreamTaskNetworkInput.java:105)
	at o
b
The error log says the chk file does not exist. Have you checked the existence of that file?
s
before running the new job, i could only check till below point if the directory exists
Copy code
/QA/rocksdb-checkpoints/social-messaging-anf/55961d5dbbc7261195e09d341420aac6/
it had below folders
Copy code
[xxxxx@xxx ~]$ hdfs dfs -ls hdfs://sf-namenode-03:8020/QA/rocksdb-checkpoints/social-messaging-anf/55961d5dbbc7261195e09d341420aac6/
Found 3 items
drwxr-xr-x   - hdfs supergroup          0 2024-04-30 01:29 hdfs://xxx:8020/QA/rocksdb-checkpoints/social-messaging-anf/55961d5dbbc7261195e09d341420aac6/chk-92
drwxr-xr-x   - hdfs supergroup          0 2024-04-30 01:29 hdfs://xxx:8020/QA/rocksdb-checkpoints/social-messaging-anf/55961d5dbbc7261195e09d341420aac6/shared
drwxr-xr-x   - hdfs supergroup          0 2024-04-29 10:06 hdfs://xxx:8020/QA/rocksdb-checkpoints/social-messaging-anf/55961d5dbbc7261195e09d341420aac6/taskowned
on running i got that File does not exist path, which is not there in the given directory
Copy code
/QA/rocksdb-checkpoints/social-messaging-anf/55961d5dbbc7261195e09d341420aac6/shared/1f131982-d77d-43c6-ae91-d518737f6e42
b
The errors looks strange which I do not have some clue. For your error1, have you ever tried to restart you v1.0 job using the checkpoint? Is that ok? Also, in your v2.0 job, do you change your job logic a lot? like adding or removing some operators.
s
v1.0 job is running all fine (checkpointing in regular intervals) and i could restart from chkpoint without issues v2.0 yes there are logic change old operator names are intact but added new operators
v1.0 code (old code)
Copy code
public static DataStream<SpTopProductMetrics> generateSpMetrics(
      DataStream<UserByProductAttribution> spMetricsByProductItem,
      int slideInterval,
      int streamInterval,
      String eventType,
      ParameterTool parameters) {

    String operatorName =
        eventType + "_" + streamInterval + "_min_timeWindow_every_" + slideInterval + "_secs";

    DataStream<Metrics> topProductMetrics = spMetricsByProductItem
        .keyBy(event -> Tuple2.of(event.getSiteId(), event.getProductId()), keyTypeInfo)
        .window(SlidingProcessingTimeWindows.of(
          Time.minutes(streamInterval),
          Time.seconds(slideInterval)))
        .reduce(new SocialMessagingReducer(), new SocialMessagingProcessor())
        .name(operatorName)
        .uid(operatorName)
        .rebalance();

    return writeMetricsToKafkaSync(parameters, eventType, streamInterval, topProductMetrics);

  }
v2.0 (new code)
Copy code
public static DataStream<SpOutputMetrics> generateSpMetrics(
      DataStream<UserByProductAttribution> spMetricsByProductItem,
      int slideInterval,
      int streamInterval,
      String eventType,
      ParameterTool parameters,
      boolean isDbStream) { <-------- OPERATORNAME would change depending on this

  
    String operatorName =
      eventType + "_" + streamInterval + "_min_timeWindow_every_" + slideInterval + "_secs";
    if (isDbStream) {
       operatorName = operatorName + "_newCode";
    }
    
      DataStream<Metrics> topProductMetrics =
        spMetricsByProductItem
          .filter(event -> StringUtils.isBlank(event.getParentGroupId()))
          .keyBy(event -> Tuple2.of(event.getSiteId(), event.getProductId()), keyTypeInfo)
          .window(SlidingProcessingTimeWindows.of(
            Time.minutes(streamInterval),
            Time.seconds(slideInterval)))
          .reduce(new SocialMessagingReducer(), new SocialMessagingProcessor())
          .name(operatorName)
          .uid(operatorName)
          .rebalance();
    
    return writeMetricsToKafkaSync(parameters, eventType, streamInterval, topProductMetrics);
  }
changes are in new code: 1. operatorName changes depending on boolean flag passed as parameter to the generateSpMetrics() 2. In generateSpMetrics() , returns DataStream<SpOutputMetrics> whereas old code returns DataStream<SpTopProductMetrics> 3. SpOutputMetrics has all/exact the fields from SpTopProductMetrics along with 1 additional new field