Skip to content

源为mongo 6.0 如果有collection 开启了changestream,源库执行原像数据清理时会在oplog中产生一条管理命令,操作config.system.preimages, 下游mongo版本低于6.0会出错 #933

@UFOXD

Description

@UFOXD

源为mongo 6.0 如果有collection 开启了changestream,源库执行原像数据清理时会在oplog中产生一条管理命令,操作config.system.preimages, 下游mongo版本低于6.0会出错

{
    "ts": {
        "T": 1763966666,
        "I": 1
    },
    "t": 9,
    "h": null,
    "v": 2,
    "op": "c",
    "ns": "admin.$cmd",
    "o": [
        {
            "Key": "applyOps",
            "Value": [
                [
                    {
                        "Key": "op",
                        "Value": "d"
                    },
                    {
                        "Key": "ns",
                        "Value": "config.system.preimages"
                    },
                    {
                        "Key": "ui",
                        "Value": {
                            "Subtype": 4,
                            "Data": "FwPQyNoWRbe2vB3xxxptUR8g=="
                        }
                    },
                    {
                        "Key": "o",
                        "Value": [
                            {
                                "Key": "_id",
                                "Value": [
                                    {
                                        "Key": "nsUUID",
                                        "Value": {
                                            "Subtype": 4,
                                            "Data": "LIV6H0eeRASplFMLdecxUQ=="
                                        }
                                    },
                                    {
                                        "Key": "ts",
                                        "Value": {
                                            "T": 1758155667,
                                            "I": 24
                                        }
                                    },
                                    {
                                        "Key": "applyOpsIndex",
                                        "Value": 0
                                    }
                                ]
                            }
                        ]
                    }
                ],
                [
                    {
                        "Key": "op",
                        "Value": "d"
                    },
                    {
                        "Key": "ns",
                        "Value": "config.system.preimages"
                    },
                    {
                        "Key": "ui",
                        "Value": {
                            "Subtype": 4,
                            "Data": "FwPQyNoWRbe2xxxvB3xptUR8g=="
                        }
                    },
                    {
                        "Key": "o",
                        "Value": [
                            {
                                "Key": "_id",
                                "Value": [
                                    {
                                        "Key": "nsUUID",
                                        "Value": {
                                            "Subtype": 4,
                                            "Data": "LIV6H0eeRASplFMLdecxUQ=="
                                        }
                                    },
                                    {
                                        "Key": "ts",
                                        "Value": {
                                            "T": 175855668,
                                            "I": 2
                                        }
                                    },
                                    {
                                        "Key": "applyOpsIndex",
                                        "Value": 0
                                    }
                                ]
                            }
                        ]
                    }
                ]
            ]
        }
    ],
    "o2": null,
    "PrevOpTime": null
}

代码中需要在 admin.$cmd中过滤掉 config.system.preimages 相关操作, 因为同版本或者高版其实也不需要同步这条命令,可以依赖DB自身的清理机制

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions