[SERVER-4413] Mongodump segfaults on certain collection names Created: 02/Dec/11  Updated: 06/Apr/23  Resolved: 09/Dec/11

Status: Closed
Project: Core Server
Component/s: Tools
Affects Version/s: 2.0.1
Fix Version/s: 2.1.0

Type: Bug Priority: Minor - P4
Reporter: Aristarkh Zagorodnikov Assignee: Kevin Matulef
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-5002 Change prohibited character sets in d... Closed
Duplicate
is duplicated by SERVER-1200 mongodump fails when a collection nam... Closed
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

We (by accident) have a collection named "'>./././". Mongodump fails to dump it, segfaulting in the process:
/usr/bin/mongodump -o "/path/to/dump" -d dbname
dbname.'>./././ to /path/to/dump/'>./././.bson
Segmentation fault



 Comments   
Comment by Jared D. Cottrell [ 28/Jun/12 ]

Yes, confirmed that the mongodump 2.1.2 behavior is:

  • skip the offending collection, logging a descriptive ERROR
  • dump the rest of the collections in the offending database
  • continue with all the other databases in the server
  • return a 0 error code

Would really prefer an error on the front end telling the user that slashes (and nulls, I guess) really aren't allowed in collection names. But this can probably get us by.

Comment by Kevin Matulef [ 27/Jun/12 ]

@Jared yeah, I realize it's unclear from the comments above. That option was discussed back in Dec, but at that time we decided not to change any existing behavior in terms of what's allowed/disallowed. We might reconsider if lots of users are hitting a wall.

Comment by Jared D. Cottrell [ 27/Jun/12 ]

Ah, sorry. I thought that based on the comments the fix was going to be to disallow the creation of collections with those characters in the first place. Testing now with 2.1.2 mongodump.

Comment by Kevin Matulef [ 27/Jun/12 ]

Hi Jared, can you verify that you are using the newer version of mongodump as well? (see comment in CS-3680)

Comment by Jared D. Cottrell [ 27/Jun/12 ]

I have verified that this issue still exists in MongoDB for Linux 2.1.2 64-bit. I created a collection called "foo/" and attempted to mongodump the server on which it was being hosted.

DATABASE: jared	 to 	/mongodump/jared
	jared.system.indexes to /mongodump/jared/system.indexes.bson
		 3 objects
	jared.system.users to /mongodump/jared/system.users.bson
		 1 objects
	jared.foo/ to /mongodump/jared/foo/.bson
Segmentation fault

Comment by Kevin Matulef [ 29/May/12 ]

I'm not sure that using a placeholder character like "_" is the best solution, since this can cause name collisions if a user has one collection named "a/b" and another named "a_b" (the same is true of any other fixed placeholder char). It seems better to me to allow the user to resolve the issue by renaming their collection. Another possibility is to prohibit "/" from appearing in collection names at all. This is related to SERVER-5002.

Comment by Benjamin Flesch [ 26/May/12 ]

+1, This issue is still alive. This has to do with filename restrictions on most operating systems, as the "/" char is not allowed when creating a new file.

A fix should be easy as in replacing all occurences of "/" with a placeholder character of your choice, for example "_".

Comment by Kevin Matulef [ 09/Dec/11 ]

The problem occurs because mongodump tries to create a file with the collection name in the filename. This breaks with collections with '/' in their name. I've modified the behavior of mongodump to log an error when this happens, and dump all other collections gracefully. For the time being, if you want to dump a collection with a '/' in the name, you will need to rename it as above.

Fixed by this commit (and few subsequent ones):
2c130588886b78c0193f15d016c1d5a28f724346

Comment by Kevin Matulef [ 05/Dec/11 ]

Looking at this issue. In the meantime, a workaround is just to rename the collection:

use admin
db.runCommand(

{renameCollection:"dbname.'>./././",to:"dbname.betterName"}

)

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