[SERVER-2305] Mongo locks should be purged (or at least ignored) when the server is started cold (while not currently running) Created: 29/Dec/10  Updated: 29/Dec/10  Resolved: 29/Dec/10

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

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

Operating System: ALL
Participants:

 Description   

A server had a failure in the middle of the night that caused a hard-reboot (nothing to do with Mongo) but then after boot the MongoDB service never started up again (turning the 1-minute of downtime into most of the night until a human would intervene.)

The issue was that the Mongo server would not start up unless all locks are cleared, this was in the log:

                            • old lock file: /data/db/mongod.lock. probably means unclean shutdown
                              recommend removing file and running --repair
                              see: http://dochub.mongodb.org/core/repair for more information
                              *************

This seems great if you are restarting and really bad for a fresh-start when Mongo is not currently running. My startup script now has a clause for:
mv /data/db/mongod.lock /data/db/mongod.lock.old

But this is a hack - the Mongo server should just ignore the locks and start-up if there is no server currently active.



 Comments   
Comment by Eliot Horowitz (Inactive) [ 29/Dec/10 ]

repair can take seconds to days depending on data size and setup, so its not something that we can always do all the time.
in your case if the db is small, the doing it all the time should be fine

Comment by phpMoAdmin [ 29/Dec/10 ]

So my hack to mv the lock file should be replaced with:
mongod --repair

Is that right? Is there any harm in always running this before Mongo-start (instead of specifically when a crash occurred)?

Also, when 1.8 becomes a production-stable version and I upgrade, at that point I would simply remove that --repair line from the startup script, right?

Is there a reason why this would not be backported to the current stable 1.6.5? It seems simple (at least in theory) to add to the mongod startup:
if (locked) {
mongod.repair();
}

Clearly my issue is user-error, but it is not really obvious that Mongo won't start up again after an unclean shutdown - I would bet that the majority of users will experience the server failing to restart at least once before learning that they need to do the --repair first.

Comment by Eliot Horowitz (Inactive) [ 29/Dec/10 ]

This is actually exactly what is supposed to happen.

After a crash, you have to run --repair, which is why it won't start up with a lock file.

With single server durability in 1.8, --repair won'e be needed so this will be automatic.

Generated at Thu Feb 08 02:59:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.