[SERVER-17515] copyDatabase fails to replicate indexes to secondary Created: 09/Mar/15  Updated: 25/Jan/17  Resolved: 09/Mar/15

Status: Closed
Project: Core Server
Component/s: Replication, Storage
Affects Version/s: 3.0.0
Fix Version/s: 3.0.1, 3.1.0

Type: Bug Priority: Critical - P2
Reporter: Asya Kamsky Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: ET
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
is related to SERVER-17432 do not apply replicated insert/delete... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Completed:
Participants:

 Description   
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



 Comments   
Comment by Githook User [ 10/Mar/15 ]

Author:

{u'username': u'monkey101', u'name': u'Dan Pasette', u'email': u'dan@10gen.com'}

Message: SERVER-17515 fixed namespace in oplog entry when using the cloner to copy indexes

(cherry picked from commit 8e6d7dc39c51c58d0158071a717113314c26b0a0)
Branch: v3.0
https://github.com/mongodb/mongo/commit/aa0d74203b5fcc43425e08af12cf27542be7c10a

Comment by Githook User [ 09/Mar/15 ]

Author:

{u'username': u'monkey101', u'name': u'Dan Pasette', u'email': u'dan@10gen.com'}

Message: SERVER-17515 fixed namespace in oplog entry when using the cloner to copy indexes
Branch: master
https://github.com/mongodb/mongo/commit/8e6d7dc39c51c58d0158071a717113314c26b0a0

Generated at Thu Feb 08 03:44:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.