[SERVER-2825] Returns exit code 0 in case of Mongo fail to start Created: 24/Mar/11  Updated: 12/Jul/16  Resolved: 25/Oct/11

Status: Closed
Project: Core Server
Component/s: Admin
Affects Version/s: 1.8.0-rc1
Fix Version/s: 2.1.0

Type: Bug Priority: Major - P3
Reporter: Artyom Bolshakov Assignee: Brandon Diamond
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux 2.6.37-ARCH #1 SMP PREEMPT Tue Mar 15 09:21:17 CET 2011 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 4600+ AuthenticAMD GNU/Linux


Operating System: Linux
Participants:

 Description   

In case of unclean shutdown mongo fail to start, but returns exit code 0.
Exit code matters when used in startup scripts.
Look at this piece of code from my ArchLinux's mongodb startup script. Here we try to start mongo an then check exit code. Mongo should return correct exit codes.
[ -z "$PID" ] && /bin/su mongodb -s /bin/bash -c "/usr/bin/mongod --config /etc/mongodb.conf &" > /var/log/mongod 2>&1
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon mongodb
stat_done
fi



 Comments   
Comment by auto [ 25/Oct/11 ]

Author:

{u'login': u'', u'name': u'Brandon Diamond', u'email': u'brandon@10gen.com'}

Message: SERVER-2825 Added async error support to mongos/d
Branch: master
https://github.com/mongodb/mongo/commit/9e4a870471afd6a018ddab16b89c35c88490ce4b

Comment by auto [ 25/Oct/11 ]

Author:

{u'login': u'', u'name': u'Brandon Diamond', u'email': u'brandon@10gen.com'}

Message: SERVER-2825 Added support for async error codes
Branch: master
https://github.com/mongodb/mongo/commit/fc640ccdca95b3d7eac6a11acab128eba3fd91b3

Comment by Brandon Diamond [ 21/Oct/11 ]

Yup, this seems like the right strategy. I'm starting implementation this morning.

Comment by Mathias Stearn [ 18/Oct/11 ]

This only applies when using --fork. I think the best way to do this is to have the parent process wait for a message from the child that it is up and running, or to wait for it to die.

I think this can be done by waitpid()ing on the child in the parent, then having the child send the parent SIGUSR2 on successful startup. This should be tested to make sure it works on all unix platforms.

Search for fork in db/cmdline.cpp to see how this is currently handled

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