You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
关联 issue #992。用户全量同步大体量时序集合(单表逻辑数据 ~226GB、压缩后 ~50GB)时,源端出现 (OutOfDiskSpace) PlanExecutor error during aggregation :: Available space ... less than the required minimum of 524288000 bytes,并伴随大量 E11000 duplicate key error ... index:_id_。排查后确认磁盘触底是被 MongoShake 的全量读行为放大,而 dup则指向目标集合未被建成时序集合。当前全量链路把时序集合当普通集合处理,存在多处适配不足。
背景
关联 issue #992。用户全量同步大体量时序集合(单表逻辑数据 ~226GB、压缩后 ~50GB)时,源端出现
(OutOfDiskSpace) PlanExecutor error during aggregation :: Available space ... less than the required minimum of 524288000 bytes,并伴随大量E11000 duplicate key error ... index:_id_。排查后确认磁盘触底是被 MongoShake 的全量读行为放大,而 dup则指向目标集合未被建成时序集合。当前全量链路把时序集合当普通集合处理,存在多处适配不足。根因(均已在代码确认)
findOptions.SetSort({_id:1})。时序集合(逻辑视图)没有 _id索引,服务端会把 find 改写为对底层system.buckets的解包聚合,再对解包后的全部测量值做阻塞排序,从而触发allowDiskUse落盘。逻辑数据越大、full_sync.reader.collection_parallel越高,并发排序落盘越严重,容易跌破 MongoDB 500MB 空闲底线。TS 分支目前只SetHint(nil)并跳过noCursorTimeout(有集合a,类型为timeseries,数据库同时中存在system.buckets.a的集合,则启动mongoshake开始同步之后,同步到该集合会报错: get next document failed: run find failed: (BadValue) error processing query: ns=dr-test.system.buckets.aTree: #897/迁移mongo的timeseries集合时报错 #784),未去掉 sort。BulkWrite,没有任何携带 timeseries:{...} 的createCollection。对于在 oplog 窗口之前就已存在的时序集合(sync_mode=all),没有 create DDL 可回放,目标端首次 insert会自动建成普通集合,丢失时序属性,并因此带上 id 唯一索引。insert_on_dup_update=true时把重复 insert 转成按 _id 的UpdateOne($set)。时序集合不支持按 _id 的任意更新,该兜底对真时序目标不可靠。影响
建议方案(分阶段)
Phase 1 —— 快速止血,低风险:
full_sync.reader.parallel_thread=1(splitVector 依赖索引,TS 无 _id 索引不适用并发分片读)。Phase 2 —— 正确性适配,后续跟进:
timeField/metaField/granularity/expireAfterSeconds)创建时序集合,避免被降级为普通集合。system.buckets.*(bucket 天然有 _id,可廉价扫描/排序,写入保留原 bucket 结构),与增量链路已有的system.buckets 处理保持一致,实现忠实复制。insert_on_dup_update兜底;改为「保证目标干净 + 单趟不中断」或基于 bucket 幂等的策略。验证建议
sync_mode=all:确认目标端被建成时序集合(db.getCollectionInfos 含 timeseries),且无 id 索引、无 E11000。相关:#992、#897、#784