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

copyDatabase fails to replicate indexes to secondary

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 3.0.1, 3.1.0
    • Affects Version/s: 3.0.0
    • Component/s: Replication, Storage
    • Fully Compatible
    • ALL

      Issue Status as of Mar 10, 2015

      ISSUE SUMMARY
      The copy database operation, including the cloneCollection and copydb commands does not correctly create oplog entires for indexes. As a result theses operations fail to correctly replicate indexes to secondaries.

      USER IMPACT
      Collections created using cloneCollection and copydb will only have the correct indexes on the primary members of a replica set on the target instance. Secondary members of the target replica set will not have the correct indexes.

      WORKAROUNDS

      • Manually create indexes after using copydb or cloneCollection.
      • Use mongodump and mongorestore to migrate data.

      AFFECTED VERSIONS: 3.0.0

      FIX VERSION
      The fix is included in the 3.0.1 production release.

      RESOLUTION DETAILS
      Change the way that the copy database operation generates oplog entires to ensure correct replication.

      Original description

      copyIndexes() in cloner.cpp is inserting oplog entries with an incorrect value for the ns field - the correct value should be the <target db name>.system.indexes instead of the <target db name>.<target collection name>. This function is used to implement the copydb and cloneCollection commands.

      --------------------------------------
      From Google Groups:

      https://groups.google.com/d/msg/mongodb-user/Q26dlFuj_gg/S_Vv5J-YgcUJ

      I am running a replica set on mongodb 3.0 and wired tiger with three members. I connect to the master and copy my database. But after it I notice, that all the indices exist as normal documents in the collection. The problem is that my application does not understand the format and crashes.
      
      > db.StationSet.find({ key: {$exists: true} })
      { "_id" : ObjectId("54fdb3f31cd6bae74eb69d68"), "key" : { "Location" : "2dsphere" }, "name" : "Location_2dsphere", "ns" : "bls_test_read.StationSet", "background" : true, "2dsphereIndexVersion" : 2 }
      
      I see this documents only an the secondaries
      

            Assignee:
            benety.goh@mongodb.com Benety Goh
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: