[SERVER-15824] Renaming collection across databases with dropTarget fails with "collection already exists" Created: 27/Oct/14  Updated: 11/Jul/16  Resolved: 30/Oct/14

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: 2.7.8
Fix Version/s: 2.8.0-rc0

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

Operating System: ALL
Participants:

 Description   

The renameCollection command will incorrectly roll back the collection drop when renaming a collection across databases with the {dropTarget: true} option. The command will fail with the error message "collection already exists" when this happens. Affects 2.7.8.

To reproduce:

> use test
switched to db test
> db.foo.drop()
true
> db.foo.insert({})
WriteResult({ "nInserted" : 1 })
> db.getSiblingDB("test2").bar.drop()
false
> db.getSiblingDB("test2").bar.insert({})
WriteResult({ "nInserted" : 1 })
> db.adminCommand({renameCollection:"test.foo",to:"test2.bar",dropTarget:true})
{
	"errmsg" : "exception: collection already exists",
	"code" : 17399,
	"ok" : 0
}



 Comments   
Comment by Githook User [ 30/Oct/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-15824 renameCollection should commit the destination coll drop
Branch: master
https://github.com/mongodb/mongo/commit/43890ae6172d427909cfe62d83377afd7c62a15f

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