Bharathkrishna G M
05/15/2023, 7:50 PMval env = StreamExecutionEnvironment.getExecutionEnvironment
env.enableCheckpointing(30000, CheckpointingMode.EXACTLY_ONCE)
env.getCheckpointConfig.enableExternalizedCheckpoints(ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION)
val inputFormat = new TextInputFormat(new Path("<gs://bucket/test_dir/>"))
inputFormat.setFilesFilter(FilePathFilter.createDefaultFilter())
// Set up the data stream by reading from the input directory in streaming mode.
val dataStream = env.readFile(inputFormat, "<gs://bucket/test_dir/>", FileProcessingMode.PROCESS_CONTINUOUSLY, 30000)
I have added the gcs-connector-latest-hadoop2.jar and /plugins/gs-fs-hadoop/
I also have configured checkpoint directory in Flink config. I see some checkpoint files getting created as well when I run the app.
Now the problem I'm facing is that when I delete and restart the app, it is reading all the files from the bucket again. ie. it is not incrementally able to stream from the GCS bucket. Feels like it's not able to use the checkpoint info, or checkpoint itself doesn't capture the info of which files were streamed ? Appreciate any inputs on this use case , thanks!Bharathkrishna G M
05/16/2023, 1:36 AMsap1ens
05/16/2023, 4:05 PMBharathkrishna G M
05/16/2023, 9:32 PM_metadata file.
But in logs, I see
[] - Triggering checkpoint 199 (type=CHECKPOINT) @ 1684272667975 for job 419beace291e58a0f660984b72fb9f03.
2023-05-16 21:31:08,486 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 199 for job 419beace291e58a0f660984b72fb9f03 (563 bytes in 359 ms).
2023-05-16 21:31:38,136 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 200 (type=CHECKPOINT) @ 1684272697975 for job 419beace291e58a0f660984b72fb9f03.
2023-05-16 21:31:38,586 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 200 for job 419beace291e58a0f660984b72fb9f03 (563 bytes in 454 ms).
and there are no errors happening here in log.
Any idea what could be missing ?sap1ens
05/16/2023, 9:35 PM_metadata file? I think until reaching a certain size Flink only uses that for storing statesap1ens
05/16/2023, 9:35 PMBharathkrishna G M
05/16/2023, 9:40 PMHow big is theIt's just 1.4KB I'm currently just testing this so the data I'm reading is just 10-12 small files.file? I think until reaching a certain size Flink only uses that for storing state_metadata
Bharathkrishna G M
05/16/2023, 9:50 PMAnother direction to investigate is recovering from a checkpoint. How do you specify it? Can you try with other sources? Or some stateful transformations?I just have these configs:
state.checkpoints.num-retained: 3
state.checkpoints.dir: "<gs://flinkapps-bucket-test-3f0a/sand-box/stream-from-gcs/flink-checkpoint/>"
I was expecting it would try to recover from latest checkpoint.
In the logs I see:
org.apache.flink.streaming.runtime.tasks.StreamTask [] - Using application-defined state backend: File State Backend (checkpoints: '<gs://flinkapps-bucket-test-3f0a/sand-box/stream-from-gcs/flink-checkpoint>', savepoints: '<gs://flinkapps-bucket-test-3f0a/sand-box/stream-from-gcs/flink-savepoint>', asynchronous: TRUE, fileStateThreshold: 20480)
and
2023-05-16 19:51:50,746 INFO org.apache.flink.streaming.api.functions.source.ContinuousFileReaderOperator [] - No state to restore for the ContinuousFileReaderOperator (taskIdx=1).sap1ens
05/16/2023, 11:08 PMBharathkrishna G M
05/17/2023, 1:02 AMsap1ens
05/17/2023, 1:23 AMBharathkrishna G M
05/22/2023, 11:28 PMsavepointDisabled: false
savepointPath: '<gs://checkpoint_path_to_metadata_folder>'