使用monstache同步MongoDB与Elasticsearch时遇ChangeStreamHistoryLost错误求助
问题:monstache同步MongoDB与Elasticsearch时出现ChangeStreamHistoryLost错误
我尝试使用monstache同步MongoDB与Elasticsearch,但运行时持续出现如下错误:
Jan 26 01:04:59 ip-172-31-1-200.eu-west-3.compute.internal monstache[25689]: ERROR 2023/01/26 01:04:59 Error starting change stream. Will retry: (ChangeStreamHistoryLost) Resume of change stream was not possible, as the resume point may no longer be in the oplog.
Jan 26 01:04:59 ip-172-31-1-200.eu-west-3.compute.internal monstache[25689]: ERROR 2023/01/26 01:04:59 Error starting change stream. Will retry: (ChangeStreamHistoryLost) Resume of change stream was not possible, as the resume point may no longer be in the oplog.
(其余重复错误省略)
已执行MongoDB oplog检查命令,结果如下:
Atlas atlas-lmkye1-shard-0 [primary] test> rs.printReplicationInfo() actual oplog size '1782.485107421875 MB' --- configured oplog size '1782.485107421875 MB' --- log length start to end '513558.99999570847 secs (142.66 hrs)' --- oplog first event time 'Fri Jan 20 2023 02:45:29 GMT+0000 (Coordinated Universal Time)' --- oplog last event time 'Thu Jan 26 2023 01:24:48 GMT+0000 (Coordinated Universal Time)' --- now 'Thu Jan 26 2023 01:24:57 GMT+0000 (Coordinated Universal Time)' Atlas atlas-lmkye1-shard-0 [primary] test>
错误原因分析
- monstache中断后重启间隔过长,超过oplog保留时长。你的oplog保留了约142.66小时(近6天),如果monstache停止运行的时间超过这个周期,它之前记录的恢复点已被oplog清理,无法继续基于该点恢复同步。
- 恢复点元数据损坏。monstache默认会在MongoDB的
monstache集合中保存同步进度(恢复点),如果该集合数据损坏或丢失,会导致它尝试从一个不存在的oplog位置恢复,触发错误。 - 短时间内MongoDB写入量突增。即便oplog配置的保留时长正常,若短时间内有大量写入操作,旧的oplog会被快速覆盖,原本在保留期内的恢复点可能被提前清理。
内容的提问来源于stack exchange,提问作者nixmind
相关产品推荐
相关产品推荐

