Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-9338

db.runCommand( { compact: '<collection>' } ) on a primary decrements maintenanceMode

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.2.3
    • Fix Version/s: 2.5.1
    • Component/s: Replication, Shell
    • Labels:
    • Environment:
      GNU/Linux
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide
      1. Create a replica set with 3 members under MongoDB 2.2.3
      2. Run db.runCommand( { compact: '<collection>' }

        ) in the mongo shell for the primary

      3. Note that this produces an error, as expected
      4. Run rs.status() - maintenanceMode will be -1 for the primary member.

      Each time step 2 above is repeated, maintenanceMode is decremented one more for the primary (with or without force: true).

      Show
      Create a replica set with 3 members under MongoDB 2.2.3 Run db.runCommand( { compact: '<collection>' } ) in the mongo shell for the primary Note that this produces an error, as expected Run rs.status() - maintenanceMode will be -1 for the primary member. Each time step 2 above is repeated, maintenanceMode is decremented one more for the primary (with or without force: true).

      Description

      We have a replica set with 3 members running MongoDB 2.2.3. After running db.runCommand(

      { compact: '<collection>' }

      ) twice on the primary (first without force: true to see the expected error message, and then again with it to actually compact the collection), rs.status() showed maintenanceMode: -2 for the primary member. After some investigation, I ran the command again (without force: true) and confirmed that it decremented again to -3:

      {
              "_id" : 0,
              "name" : "ec2-xxx.compute-1.amazonaws.com:27017",
              "health" : 1,
              "state" : 1,
              "stateStr" : "PRIMARY",
              "uptime" : 2833099,
              "optime" : Timestamp(1365604059000, 1),
              "optimeDate" : ISODate("2013-04-10T14:27:39Z"),
              "maintenanceMode" : -3,
              "self" : true
      },

      After stepping down the primary, maintenanceMode was not shown in rs.status() on the new primary, but on stepping that one down and the original primary taking over again, it was still -3 there. Restarting mongod appears to have reset maintenanceMode now and it no longer appears in rs.status().

      I couldn't find any mention of this in the documentation or anywhere online. I'm not familiar with C++ so could easily have missed something, but it looks to me as if the problem might be that there is no check on theReplSet->isSecondary() when decrementing maintenanceMode in Command::execCommand, to correspond with that check when incrementing it earlier in the method. I have created a commit with this possible fix:

      https://github.com/jennyd/mongo/commit/83a4b60e72d67bde124fed8072994da40945f297

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: