[SERVER-9354] copyCollection cannot append namespaces with options Created: 15/Apr/13  Updated: 05/Apr/17  Resolved: 06/Mar/17

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: 2.4.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Jeremy Assignee: Maria van Keulen
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

linux centos 64bit


Backwards Compatibility: Fully Compatible
Operating System: Linux
Steps To Reproduce:

Example:

 db.runCommand({cloneCollection: 'mydb.map', from:'[source address]', query: { _id: 'TDL-TRIPWL-2013'  }});
{ "ok" : 1 }

Above works even though .map collection exists.

db.runCommand({cloneCollection: 'mydb.category', from:'[source address]', query: { event_name: 'TDL-TRIPWL-2013'  }});
{ "ok" : 0, "errmsg" : "collection already exists" }

But this does not...what is the difference?

I thought maybe it's the use of _id.. but this didn't work either:

db.runCommand({cloneCollection: 'mydb.category', from:'[source address]', query: { _id:  ObjectId("5154d54aecfdf41427000041")  }});
{ "ok" : 0, "errmsg" : "collection already exists" }

Info on my 2 collections:

{
	"ns" : "rt01.map",
	"count" : 9,
	"size" : 7840,
	"avgObjSize" : 871.1111111111111,
	"storageSize" : 36864,
	"numExtents" : 1,
	"nindexes" : 1,
	"lastExtentSize" : 36864,
	"paddingFactor" : 1.0020000000000011,
	"systemFlags" : 1,
	"userFlags" : 0,
	"totalIndexSize" : 8176,
	"indexSizes" : {
		"_id_" : 8176
	},
	"ok" : 1
}
 
{
	"ns" : "rt01.category",
	"count" : 575,
	"size" : 233208,
	"avgObjSize" : 405.5791304347826,
	"storageSize" : 696320,
	"numExtents" : 4,
	"nindexes" : 3,
	"lastExtentSize" : 524288,
	"paddingFactor" : 1.5120000000000196,
	"systemFlags" : 1,
	"userFlags" : 0,
	"totalIndexSize" : 130816,
	"indexSizes" : {
		"_id_" : 32704,
		"name_1_event_name_1" : 49056,
		"event_name_1_name_1" : 49056
	},
	"ok" : 1
}

Sprint: Storage 2017-03-27
Participants:

 Description   

According to docs, cloneCollection "appends documents in the remote collection to the destination collection." if the collection already exists. I am seeing odd behavior when trying to do this.



 Comments   
Comment by Eric Milkie [ 15/Apr/13 ]

You could use mongodump and mongorestore with the --collection parameter to export and import the collection's data.

Comment by Jeremy [ 15/Apr/13 ]

Is there a work around to override and clear that out so I can append to it?

Comment by Eric Milkie [ 15/Apr/13 ]

It turns out that, due to a bug, creating a collection with the CreateCollection command will produce that "create" field in the namespace spec document. Such namespaces will not be clonable.
I'll edit this JIRA ticket to reflect the exact issue.

Comment by Jeremy [ 15/Apr/13 ]

filtered by the to collections im working with:

db.system.namespaces.find({name:/map/})
{ "name" : "rt01.map.$_id_" }
{ "name" : "rt01.map" }

db.system.namespaces.find({name:/category/})
{ "name" : "rt01.category", "options" : { "create" : "category" } }
{ "name" : "rt01.category.$_id_" }
{ "name" : "rt01.category.$name_1_event_name_1" }
{ "name" : "rt01.category.$event_name_1_name_1" }

Comment by Eric Milkie [ 15/Apr/13 ]

Looking at the code, it seems like we try to create the namespace on the destination if the source namespace has an options field in its description.

Can you post the output of db.system.namespaces.find()?

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