Antti Ahonen
03/28/2024, 8:44 AMCaused by: java.lang.IllegalStateException: userVisibleTail should not be larger than offset. This is a bug.
at org.apache.flink.util.Preconditions.checkState(Preconditions.java:193)
at org.apache.flink.streaming.api.operators.collect.AbstractCollectResultBuffer.sanityCheck(AbstractCollectResultBuffer.java:144)
at org.apache.flink.streaming.api.operators.collect.AbstractCollectResultBuffer.dealWithResponse(AbstractCollectResultBuffer.java:94)
at org.apache.flink.streaming.api.operators.collect.CollectResultFetcher.next(CollectResultFetcher.java:150)
at org.apache.flink.streaming.api.operators.collect.CollectResultIterator.nextResultFromFetcher(CollectResultIterator.java:126)
at org.apache.flink.streaming.api.operators.collect.CollectResultIterator.hasNext(CollectResultIterator.java:100)
at java.base/java.util.Iterator.forEachRemaining(Unknown Source)
at com.mycompany.flink.FlinkApp.main(FlinkApp.java:89)
Here is the code that I run inside the jobmanager as a jar:
public static void main(String[] args) {
var environment = StreamExecutionEnvironment.getExecutionEnvironment();
environment.setRestartStrategy(RestartStrategies.fixedDelayRestart(5, Time.seconds(5)));
environment.setStateBackend(new HashMapStateBackend());
environment.enableCheckpointing(3000, CheckpointingMode.EXACTLY_ONCE);
environment.setParallelism(1);
// make sure 500 ms of progress happen between checkpoints
environment.getCheckpointConfig().setMinPauseBetweenCheckpoints(500);
// checkpoints have to complete within one minute, or are discarded
environment.getCheckpointConfig().setCheckpointTimeout(60000);
// only two consecutive checkpoint failures are tolerated
environment.getCheckpointConfig().setTolerableCheckpointFailureNumber(2);
// allow only one checkpoint to be in progress at the same time
environment.getCheckpointConfig().setMaxConcurrentCheckpoints(1);
// enable externalized checkpoints which are retained
// after job cancellation
environment
.getCheckpointConfig()
.setExternalizedCheckpointCleanup(CheckpointConfig.ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION);
// enables the unaligned checkpoints
environment.getCheckpointConfig().enableUnalignedCheckpoints();
// sets the checkpoint storage where checkpoint snapshots will be written
Configuration config = new Configuration();
config.set(CheckpointingOptions.CHECKPOINT_STORAGE, "filesystem");
config.set(CheckpointingOptions.CHECKPOINTS_DIRECTORY, "file:////tmp///flink-checkpoints-directory");
config.set(ExecutionCheckpointingOptions.ENABLE_CHECKPOINTS_AFTER_TASKS_FINISH, true);
environment.configure(config);
var flinkTableEnvironment = StreamTableEnvironment.create(environment);
flinkTableEnvironment.executeSql("CREATE DATABASE IF NOT EXISTS `test`;").print();
flinkTableEnvironment.executeSql("USE `test`;").print();
flinkTableEnvironment
.executeSql(
"CREATE TABLE `mytable` (" + "\n" +
"key STRING," + "\n" +
"`offset` BIGINT METADATA VIRTUAL," + "\n" +
"`ts` TIMESTAMP(3) METADATA FROM 'timestamp'," + "\n" +
"WATERMARK FOR ts AS ts" + "\n" +
") WITH (" + "\n" +
"'connector' = 'kafka'," + "\n" +
"'topic' = 'mytopic'," + "\n" +
"'properties.bootstrap.servers' = 'redpanda:29092'," + "\n" +
"'properties.group.id' = 'testGroup1'," + "\n" +
"'properties.auto.offset.reset' = 'earliest'," + "\n" +
"'value.format' = 'avro-confluent'," + "\n" +
"'value.avro-confluent.url' = 'http://redpanda:8081'," + "\n" +
"'value.fields-include' = 'EXCEPT_KEY'," + "\n" +
"'key.fields' = 'key'," + "\n" +
"'key.format' = 'raw'," + "\n" +
"'scan.startup.mode' = 'group-offsets'" + "\n" +
");"
)
.print();
var query = flinkTableEnvironment.sqlQuery("SELECT * FROM `mytable`");
try (var collected = flinkTableEnvironment.toChangelogStream(query).executeAndCollect("myjob")) {
collected.forEachRemaining(row -> log.info("kind {}", row.getKind()));
}
}
Any idea what is wrong with the config? I tried both stopping the job with savepoint and resuming from there, or cancelling the job and resuming from a checkpoint but they both result in the same exceptionrmetzger
04/02/2024, 8:32 AMrmetzger
04/02/2024, 8:33 AM:latest docker image?Antti Ahonen
04/02/2024, 8:34 AMrmetzger
04/02/2024, 8:38 AMrmetzger
04/02/2024, 8:38 AMAntti Ahonen
04/02/2024, 8:42 AM