Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
None
Description
This lists a couple of fields that are present on primaries only:
http://docs.mongodb.org/manual/reference/replication-info/#primary-nodes
In fact, they are present only when the oplog is empty, see:
https://github.com/mongodb/mongo/blob/v2.4/src/mongo/shell/db.js#L815
To confirm:
// delete oplog, crete new and empty
|
testReplSet:PRIMARY> use local
|
switched to db local
|
testReplSet:PRIMARY> db.oplog.rs.drop()
|
true
|
testReplSet:PRIMARY> db.createCollection("oplog.rs", {capped:1, size: 2*1024*1024, autoIndexId:false}) |
{ "ok" : 1 } |
// run the command to get the fields
|
testReplSet:PRIMARY> db.getReplicationInfo()
|
{
|
"logSizeMB" : 2, |
"usedMB" : 0, |
"errmsg" : "objects not found in local.oplog.$main -- is this a new and empty db instance?", |
"oplogMainRowCount" : 0 |
}
|
// insert anything, to populate the oplog
|
testReplSet:PRIMARY> use test
|
switched to db test
|
testReplSet:PRIMARY> db.foo.insert({"a" : 1}) |
// and now the extra fields are gone
|
testReplSet:PRIMARY> db.getReplicationInfo()
|
{
|
"logSizeMB" : 2, |
"usedMB" : 0.01, |
"timeDiff" : 0, |
"timeDiffHours" : 0, |
"tFirst" : "Mon May 06 2013 14:17:09 GMT+0100 (IST)", |
"tLast" : "Mon May 06 2013 14:17:09 GMT+0100 (IST)", |
"now" : "Mon May 06 2013 14:17:11 GMT+0100 (IST)" |
}
|