您好:kafka在exactly-once语义下,从svaepoint恢复报错。初步排查认为是kafka事务使用了旧的epoch。请问这个问题怎么处理?
//todo 通过配置传进来
env.setParallelism(1);
env.enableCheckpointing(600000L, CheckpointingMode.EXACTLY_ONCE);
// checkpoint的清除策略(即使任务被显示地取消也会保留checkpoint)
env.getCheckpointConfig()
.enableExternalizedCheckpoints(CheckpointConfig.ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION);
env.getCheckpointConfig().setCheckpointTimeout(60000);
env.getCheckpointConfig().setTolerableCheckpointFailureNumber(10);
//TODO 生产中必须使用 HDFS
env.setStateBackend(new FsStateBackend("hdfs://10.10.98.226:8020/tmp/checkpoint66"));
StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);
public static final String TABLE_NAME = "KafkaTable";
public static final String COLUMN_NAME = "source_value";
public static final String KAFKA_TABLE_FORMAT =
"CREATE TABLE "+TABLE_NAME+" (\n" +
" "+COLUMN_NAME+" STRING\n" +
") WITH (\n" +
" 'connector' = 'kafka',\n" +
" 'topic' = '%s',\n" +
" 'properties.bootstrap.servers' = '%s',\n" +
" 'sink.semantic' = 'exactly-once',\n" +
" 'properties.transaction.timeout.ms' = '30000',\n" +
" 'format' = 'dbz-json'\n" +
")\n";
org.apache.kafka.common.errors.ProducerFencedException: Producer attempted an operation with an old epoch. Either there is a newer producer with the same transactionalId,
or the producer's transaction has been expired by the broker. while recovering transaction KafkaTransactionState [transactionalId=Source:
TableSourceScan(table=[[default_catalog, default_database, debezium_source]], fields=[data]) -> Sink: Sink(table=[default_catalog.default_database.KafkaTable],
fields=[data])-7df19f87deec5680128845fd9a6ca18d-0, producerId=239009, epoch=216]. Presumably this transaction has been already committed before*来自志愿者整理的flink邮件归档
properties.transaction.timeout.ms' = '30000' 配置的太短了,30s transactionalId 就过期了。 估计 都来不去启动吧 官网的原文 https://ci.apache.org/projects/flink/flink-docs-release-1.13/docs/connectors/datastream/kafka/ Semantic.EXACTLY_ONCE mode relies on the ability to commit transactions that were started before taking a checkpoint, after recovering from the said checkpoint. If the time between Flink application crash and completed restart is larger than Kafka’s transaction timeout there will be data loss (Kafka will automatically abort transactions that exceeded timeout time). Having this in mind, please configure your transaction timeout appropriately to your expected down times.*来自志愿者整理的FLINK邮件归档
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。