storm-kafka WARN storm.kafka.KafkaUtils - Got fetch request with offset out of range

当kafka-spout拉取数据时遇到offset超出范围的警告,常见解决方案包括修改SpoutConfig.zkRoot和设置forceFromStart为true,但这些在实际操作中可能无效。问题源于storm启动时默认从ZK读取可能已不存在的旧offset。在PartitionManager类的fill方法中找到并修改相应逻辑可能是有效的解决策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

kafka-spout在拉取数据的时候,offset超出了范围

78591927 [Thread-17-spout] WARN  storm.kafka.PartitionManager - Using new offset: 686146
78591927 [Thread-15-spout] WARN  storm.kafka.KafkaUtils - Got fetch request with offset out of range: [349915]; retrying with default start offset time from configuration. configured start offset time: [-2]

网上说的最多的解决办法
1.修改SpoutConfig.zkRoot 值
String zkRoot = “”;
SpoutConfig spoutConf = new SpoutConfig(hosts, topic, zkRoot, id);
2.将spoutConf.forceFromStart 设为 true;
原因:
storm启动的时候,默认是从头读取-2,当kafkaspout的task出错时候,会重新启动,这时候offset就会从zk中最老的offset,但kafka数据只会保存一段时间,从zk中读取道德offset的数据可能已经不存在,超过现在的范围。
kafkaspout读取的3种选项
-2: 从最老的开始读
-1: 从最近的开始读
0: 从Zk中读

在自己的亲自试验中上面的解决办法并没有作用,而且-2,-1, 0不知道在哪里设置
在GitHub上面看见较多的办法,这是kafka自身的问题,需要自己修改源码,在storm-kafka的文件中有PartitionManager类,在此类中有一个private void fill()方法,修改此方法中的

try {
msgs = KafkaUtils.fetchMessages(this._spoutConfig, this._consumer, this._partition, offset);
} catch (UpdateOffsetException var15) { this._emittedToOffset = Long.valueOf(KafkaUtils.getOffset(this._consumer, this._spoutConfig.topic, this._partition.partition, this._spoutConfig));
            LOG.warn("Using new offset: {}", this._emittedToOffset);
            return;
        }

在return之前添加

 if (had_failed) {
    failed.remove(offset);
 }
WARN Completed request:RequestHeader(apiKey=OFFSET_FETCH, apiVersion=7, clientId=__dms_metrics_server_172.31.2.95:9091, correlationId=213512) -- {group_id=clickhouse_ai_correction_biz_log_group,topics=null,require_stable=false,_tagged_fields={}},response:{throttle_time_ms=0,topics=[{name=ai-correction-biz-log,partitions=[{partition_index=2,committed_offset=41672148,committed_leader_epoch=-1,metadata=,error_code=0,_tagged_fields={}},{partition_index=6,committed_offset=41673395,committed_leader_epoch=-1,metadata=,error_code=0,_tagged_fields={}},{partition_index=0,committed_offset=41672529,committed_leader_epoch=-1,metadata=,error_code=0,_tagged_fields={}},{partition_index=3,committed_offset=41674001,committed_leader_epoch=-1,metadata=,error_code=0,_tagged_fields={}},{partition_index=1,committed_offset=41675872,committed_leader_epoch=-1,metadata=,error_code=0,_tagged_fields={}},{partition_index=4,committed_offset=41675003,committed_leader_epoch=-1,metadata=,error_code=0,_tagged_fields={}},{partition_index=7,committed_offset=41672646,committed_leader_epoch=-1,metadata=,error_code=0,_tagged_fields={}},{partition_index=5,committed_offset=41669132,committed_leader_epoch=-1,metadata=,error_code=0,_tagged_fields={}}],_tagged_fields={}}],error_code=0,_tagged_fields={}} from connection 172.31.2.95:9091-172.31.2.219:59779-4437775;totalTime:63.807,requestQueueTime:3.386,localTime:0.083,remoteTime:0.0,throttleTime:0.0,responseQueueTime:60.311,sendTime:0.025,securityProtocol:PLAINTEXT,principal:User:ANONYMOUS,listener:MAINTAIN,appendTime:0.0,localFlushTime:0.0 (kafka.request.logger)
最新发布
06-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值