[SERVER-13984] behavior change: 2.6 preserves autoIndexId property on renameCollection across DBs Created: 18/May/14  Updated: 10/Dec/14  Resolved: 24/May/14

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 2.6.0, 2.6.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Asya Kamsky Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

In 2.4 and prior, renameCollection across databases would not preserve autoIndexId property of the collection.

Starting with 2.5.5 it does respect the autoIndexId setting and preserves it in the new collection.

Since MR uses a temp DB and then renames the temp collection into the target DB, and MR uses autoIndexId "false" this breaks replication performance when this causes MR results to have on "_id" index in the result collection.



 Comments   
Comment by Eliot Horowitz (Inactive) [ 24/May/14 ]

I think this change is correct.
If this does cause an M/R issue, can you open a new ticket for that?

Comment by Asya Kamsky [ 18/May/14 ]

It looks like it was the work to defer building indexes from SERVER-8412 and SERVER-11611 that "fixed" the bug where we used to "ignore" things like autoIndexId property when doing rename across DBs in 2.4 but we "respect" it in 2.6. Code comparison:

https://github.com/mongodb/mongo/commit/0abf27ae913dc3ca15b97480b1e35775ec2efbda#diff-892538d882b517875a5199201a5ef016L164

Reproducer with 2.4

> db.version()
2.4.8
> db
mrtemp1
> db.dropDatabase()
{ "dropped" : "mrtemp1", "ok" : 1 }
> db.getSiblingDB("mrtemp2").dropDatabase()
{ "dropped" : "mrtemp2", "ok" : 1 }
> db.createCollection("noindex",{autoIndexId:false})
{ "ok" : 1 }
> db.system.namespaces.find()
{ "name" : "mrtemp1.noindex", "options" : { "create" : "noindex", "autoIndexId" : false } }
> db.adminCommand({renameCollection:"mrtemp1.noindex",to:"mrtemp2.noindex"})
{ "ns" : "mrtemp1.noindex", "ok" : 1 }
> db.getSiblingDB("mrtemp2").system.namespaces.find()
{ "name" : "mrtemp2.system.indexes" }
{ "name" : "mrtemp2.noindex.$_id_" }
{ "name" : "mrtemp2.noindex" }

Reproducer with 2.6

> use mrtemp1
> db.version()
2.6.1
> db.dropDatabase()
{ "dropped" : "mrtemp1", "ok" : 1 }
> db.getSiblingDB("mrtemp2").dropDatabase()
{ "dropped" : "mrtemp2", "ok" : 1 }
> db.createCollection("noindex",{autoIndexId:false})
{ "ok" : 1 }
> db.system.namespaces.find()
{ "name" : "mrtemp1.noindex", "options" : { "autoIndexId" : false } }
> db.adminCommand({renameCollection:"mrtemp1.noindex",to:"mrtemp2.noindex"})
{ "ok" : 1 }
> db.getSiblingDB("mrtemp2").system.namespaces.find()
{ "name" : "mrtemp2.noindex", "options" : { "autoIndexId" : false } }

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