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

db.repairDatabase() doesn't work on Secondarys

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.4.6
    • Component/s: Replication
    • None
    • Environment:
      3.2.0-54-generic #82-Ubuntu SMP Tue Sep 10 20:08:42 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
      Ubuntu 12.04.3 LTS
      MongoDB 2.4.6
    • ALL
    • Hide

      On primary create DB with test collection.

      > use testDB
      > db.testCollection.insert({ test : 1})
      

      On secondary go to DB an try to run Repair command

      > use testDB
      switched to db testDB
      > rs.slaveOk()
      > db.repairDatabase()
      {
          "ok" : 0,
          "errmsg" : "clone failed for testDB with error: namespace query failed testDB.system.namespaces"
      }
      
      Show
      On primary create DB with test collection. > use testDB > db.testCollection.insert({ test : 1}) On secondary go to DB an try to run Repair command > use testDB switched to db testDB > rs.slaveOk() > db.repairDatabase() { "ok" : 0, "errmsg" : "clone failed for testDB with error: namespace query failed testDB.system.namespaces" }

      We try to run Repair in our ReplicaSet to improve disk usage.
      We want to repair each secondary and then after stepDown the last primary.

      If we try to run repair on a secondary we receive an error:

      > db.repairDatabase()
      {
          "ok" : 0,
          "errmsg" : "clone failed for testDB with error: namespace query failed testDB.system.namespaces"
      }
      

      We used the mongo shell and set rs.slaveOk(). We also wrote a python script to do this task, which fails with the same Error.
      RepairDatabase() works on a single mongod without replicatset config.

      Some more debugging:

      > use testDB
      > db.system.namespaces.find();
      { "name" : "testDB.system.indexes" }
      { "name" : "testDB.testCollection.$_id_" }
      { "name" : "testDB.testCollection" }
      > db.createCollection( "testDB.system.namespaces" );
      { "note" : "from execCommand", "ok" : 0, "errmsg" : "not master" }
      > rs.slaveOk()
      > db.createCollection( "testDB.system.namespaces" );
      { "note" : "from execCommand", "ok" : 0, "errmsg" : "not master" }
      

      We ran the createCollection command on the Primary before as well, but still don't see the namespace in the listing.
      If we run the command on the primary again

      > db.createCollection( "testDB.system.namespaces" );
      { "ok" : 0, "errmsg" : "collection already exists" }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            steffen Steffen
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: