[SERVER-4138] Mongo crashes in windows if database name is a reserved file name Created: 24/Oct/11  Updated: 11/Jul/16  Resolved: 07/May/12

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: 2.0.1
Fix Version/s: 2.1.2

Type: Bug Priority: Major - P3
Reporter: Yann Schwartz Assignee: Tad Marshall
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows


Operating System: Windows
Participants:

 Description   
  • Repro

Pretty easy to reproduce:

Example:
in any mongo shell
> use Aux
> show collections

mongod process crashes leaving this log:

Mon Oct 24 20:11:16 [conn1] ERROR: Uncaught std::exception:
boost::filesystem::file_size: The system cannot find the file
specified: "e:\dat
a\mongodb\Aux.ns", terminating
Mon Oct 24 20:11:16 dbexit:
Mon Oct 24 20:11:16 [conn1] shutdown: going to close listening
sockets...
Mon Oct 24 20:11:16 [conn1] closing listening socket: 436
Mon Oct 24 20:11:16 [conn1] closing listening socket: 440
Mon Oct 24 20:11:16 [initandlisten] now exiting
Mon Oct 24 20:11:16 [conn1] shutdown: going to flush diaglog...
Mon Oct 24 20:11:16 dbexit: ; exiting immediately
Mon Oct 24 20:11:16 [conn1] shutdown: going to close sockets...

The problem comes from an old legacy limitation of Windows, there are
some file names/directories which are reserved and cannot be used.

The list can be found here :
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx

(quote
"CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8,
COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also
avoid these names followed immediately by an extension; for example,
NUL.txt is not recommended. "

What happens is mongo is trying to create an Aux.ns file, the API used
does not create it, and mongo crashes the first time it tries to
access the underlying file.

I don't know what would be the best fix. Escaping the problematic
names would be necessary, but then it could mess with compatibility
with old backups made on unix systems.



 Comments   
Comment by auto [ 07/May/12 ]

Author:

{u'login': u'tadmarshall', u'name': u'Tad Marshall', u'email': u'tad@10gen.com'}

Message: SERVER-4138 give specific error on reserved Windows db name

If the user tries to create a database on the Windows version
of mongod that uses a name that is reserved on Windows, give a
specific error stating that the chosen name is reserved. Display
the assertion code when any uassert testing for an invalid name
is triggered.
Branch: master
https://github.com/mongodb/mongo/commit/84e3c010d4e672751c7e96e169faa3f1d1c5c90f

Comment by Tad Marshall [ 06/May/12 ]

> use com9
switched to db com9
> db.foo.insert({a:1})
db name "com9" is a reserved name

Sun May 06 17:11:07 [conn1] warning database \data\db\ com9 could not be opened
Sun May 06 17:11:07 [conn1] DBException 16185: db name "com9" is a reserved name

Comment by Tad Marshall [ 06/May/12 ]

No crash or server shutdown in 2.1.2-pre-, just error messages returned to user and output in log.

> use aux
switched to db aux
> db.foo.insert({a:1})
couldn't get file length when opening mapping /data/db/aux.ns boost::filesystem::file_size: The system cannot find the file specified: "\data\db\aux.ns"
> use com1
switched to db com1
> db.foo.insert({a:1})
couldn't get file length when opening mapping /data/db/com1.ns boost::filesystem::file_size: The system cannot find the file specified: "\data\db\com1.ns"

Sun May 06 14:43:16 [conn1] opening db:  aux
Sun May 06 14:43:16 [conn1] warning database \data\db\ aux could not be opened
Sun May 06 14:43:16 [conn1] couldn't get file length when opening mapping /data/db/aux.ns boost::filesystem::file_size: The system cannot find the file specified: "\data\db\aux.ns"
Sun May 06 14:44:35 [conn1] opening db:  com1
Sun May 06 14:44:35 [conn1] warning database \data\db\ com1 could not be opened
Sun May 06 14:44:35 [conn1] couldn't get file length when opening mapping /data/db/com1.ns boost::filesystem::file_size: The system cannot find the file specified: "\data\db\com1.ns"

It would be a little cleaner to reject the unusable name immediately (instead of saying "switched to db aux" and "opening db: aux") and also to make the error specify that the filename is unusable because it is a reserved filename on Windows.

Comment by Yann Schwartz [ 24/Oct/11 ]

BTW, using the API to access a db with a reserved name also crashes mongod. It's not a shell problem.

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