mongod keeps logging that local.oplog.rs is missing after you add a replica set name
Your error
Unable to retrieve storageStats in $collStats stage :: caused by :: Collection [local.oplog.rs] not found.1 more line it can showFix it fast
Most common cause, 1 of 2The node runs with replSetName, but rs.initiate() was never called
Finish the documented setup.
mongosh --port 27017
rs.initiate({
_id: "rs0",
members: [ { _id: 0, host: "mongodb0.example.net:27017" } ]
})Short answer
The repeating warning Collection [local.oplog.rs] not found comes from mongod's FTDC diagnostics, which run $collStats on the oplog once a node starts in replica set mode. A member that never ran rs.initiate() has no oplog yet, and arbiters, which never have one, logged it until 7.0.11. Run rs.initiate() once, or upgrade arbiters to 7.0.11 or later (8.0, 8.3, 9.0).
Which cause do you have?
Connect to the node that writes the warning and count the documents in local.system.replset, where a member keeps its replica set configuration. A count of 0 means the set was never initiated (cause 1); a count of 1 sends you to cause 2.
mongosh --port 27017 --quiet --eval 'print(db.version()); print(db.getSiblingDB("local").system.replset.countDocuments())'Then find the line you see in this list and open its fix:
- 1The node runs with replSetName, but rs.initiate() was never called
local.system.replset is empty, and the warning began right after you added replication.replSetName and restarted - 2The warning comes from an arbiter on a 7.0 release before 7.0.11
rs.conf() shows arbiterOnly: true for the noisy host, and data-bearing members of the same set log nothing similar
What does the error look like?
Unable to retrieve storageStats in $collStats stage :: caused by :: Collection [local.oplog.rs] not found."msg":"Aggregate command executor error","attr":{"error":{"code":26,"codeName":"NamespaceNotFound"
Cause 1 of 2
The node runs with replSetName, but rs.initiate() was never called
You seelocal.system.replset is empty, and the warning began right after you added replication.replSetName and restarted
Check
Collection [local.oplog.rs] not found shows up when mongod starts in replica set mode before the set has a configuration. As soon as a data-bearing node runs in replica set mode, FTDC registers periodic $collStats collectors, one of them for local.oplog.rs, and on a fresh member that collection does not exist yet. The setup is half done, not broken.
mongosh --port 27017 --eval 'db.getSiblingDB("local").getCollectionNames()'Fix
Finish the documented setup. Connect to one member only and initiate the set, using hostnames rather than bare IP addresses in the member list. Initiate on a single member; the others join through rs.add() or the members array.
mongosh --port 27017
rs.initiate({
_id: "rs0",
members: [ { _id: 0, host: "mongodb0.example.net:27017" } ]
})Verify
rs.status() lists the member as PRIMARY, and oplog.rs now appears in the collection names of the local database.
mongosh --port 27017 --quiet --eval 'printjson(rs.status().members.map(m => m.stateStr)); printjson(db.getSiblingDB("local").getCollectionNames())'Confirmed by mongodb.com
Cause 2 of 2
The warning comes from an arbiter on a 7.0 release before 7.0.11
You seers.conf() shows arbiterOnly: true for the noisy host, and data-bearing members of the same set log nothing similar
Check
An arbiter keeps no data, so it never has an oplog. Before 7.0.11 (the ticket was filed against 7.0.4), mongod still ran the FTDC collection stats collector on arbiters, and the NamespaceNotFound line was written about once a second, mostly costing log space.
mongosh --port 27017 --eval 'rs.conf().members.filter(m => m.arbiterOnly).map(m => m.host)'Fix
Upgrade the arbiter to a release where SERVER-85279 is fixed: 7.0.11 or later in the 7.0 series, or 8.0 and newer.
# on the arbiter host, after installing the newer package
sudo systemctl restart mongod
mongosh --port 27017 --eval 'db.version()'Verify
db.version() on the arbiter reports 7.0.11 or newer, and its log no longer fills with the oplog.rs NamespaceNotFound line.
tail -n 200 /path/to/mongod.log | grep -c "local.oplog.rs] not found"Confirmed by jira.mongodb.org
How do I stop it coming back?
- Keep rs.initiate() in the same provisioning script that adds replSetName, so no member sits in replica set mode without a config.
- Run arbiters on the same patch release as the data-bearing members, and include them in every rolling upgrade.
- After any mongod config change, check whether the process is still running before reading warnings, so FTDC noise is never taken for the reason a start failed.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.