Mongodb – What does maintenanceMode -7 mean on a mongo primary

mongodb

I've recently promoted a new member to primary of a mongo replicaset. Things seem to be running smoothly for several days and am not seeing any application symptoms of any problems. However peeking at rs.status() today I noticed it's listing maintenanceMode -7. I didn't think this should be possible as it's the primary. I'm having trouble finding anything useful in the docs on what this means.

What does this mean?

    {
        "_id" : 26,
        "name" : "mongohost5:27032",
        "health" : 1,
        "state" : 1,
        "stateStr" : "PRIMARY",
        "uptime" : 106966,
        "optime" : Timestamp(1379627877000, 77),
        "optimeDate" : ISODate("2013-09-19T21:57:57Z"),
        "maintenanceMode" : -7,
        "self" : true
    }

Best Answer

Maintenance mode is used when running certain commands, generally the compact command. What you have here is the bug mentioned in SERVER-9338 whereby I am guessing you have run the compact command against your nodes several times. There are some circumstances, especially when run on a primary when it will usually cause a change of state (i.e. it's not primary when the compact finishes), that cause maintenanceMode to be erroneously decremented.

As of writing this answer this is fixed in the development branch and has been marked for backport, though it has not (yet) been targeted for a release in the earlier versions. Until the fix is released it should be safe to ignore the value, but I will do some testing to confirm and report back.