-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Fully Compatible
-
ALL
-
First of all, thanks for developing MongoDB, and releasing it as open source software!
We have been using MongoDB with the --directoryperdb option, and it's been running great. As the data in the system has expanded, we added some additional hard drives to the server, to reduce spindle contention and increase the amount o
f disk space available. To accomplish this, we used a simple method of creating symlinks from the Mongo data directory out to per-database directories on separate drives. Others online have done similar things before us (Google: mongodb directoryperdb symlink).
Recently, we discovered that if you drop such a database from the Mongo shell, Mongo will simply remove the symlink, without dereferencing it. The end result is that the symlink goes away, and the data on the additional drive becomes orphaned. Worse, if you later recreate or otherwise try to access the same database again, Mongo has no memory of the symlink or the other drive, and creates the database anew.
The end result is that under this configuration, if you drop and then re-add such a database, the new data will be written to the original drive.
I have attached a patch to MongoDB 2.4.5 that changes this behavior. In normal circumstances, it should work just as it did before. However, in the situation described above, MongoDB will instead follow the symlink, and remove the contents of the target directory instead.
The theory is that since the symlink was placed there by a system administrator, it will be left alone. This makes creating and deleting a database a symmetrical operation from the Mongo shell. Creating and deleting the symlink and provisioning additional hard drives is also a symmetrical operation for the system administrator.