-
Type: Bug
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Server Programmability
On Linux, If attempting to start a mongod server and forking it but a server is already running (with the same config) then the process call will return an exit code of 1 but the log will report an exitCode of 48:
[ec2-user@ip-172-31-29-105 run_dir]$ ./mongod70 -f /etc/mongod.conf about to fork child process, waiting until server is ready for connections. forked process: 29547 child process started successfully, parent exiting [ec2-user@ip-172-31-29-105 run_dir]$ ./mongod70 -f /etc/mongod.conf about to fork child process, waiting until server is ready for connections. forked process: 29614 ERROR: child process failed, exited with 1 To see additional information in this output, start without the "--fork" option. [ec2-user@ip-172-31-29-105 run_dir]$ echo $? 1
The relevant log line:
{"t":{"$date":"2024-06-12T00:37:54.254+00:00"},"s":"I", "c":"CONTROL", "id":23138, "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":48}}
If running without forking then an exit code of 48 is returned.
Expected behaviour is for the process to return an exit code of 48, matching the logs and non-forking behaviour.
This applies to mongod version 7.0 (7.0.5 and 7.0.11 tested) and 8.0.0 . Versions 6.0 and earlier of mongod return an exit code of 48 (and report exitCode 48 in logs) in the same situation:
[ec2-user@ip-172-31-29-105 run_dir]$ ./mongod60 -f /etc/mongod.conf about to fork child process, waiting until server is ready for connections. forked process: 29421 child process started successfully, parent exiting [ec2-user@ip-172-31-29-105 run_dir]$ echo $? 0 [ec2-user@ip-172-31-29-105 run_dir]$ ./mongod60 -f /etc/mongod.conf about to fork child process, waiting until server is ready for connections. forked process: 29488 ERROR: child process failed, exited with 48 To see additional information in this output, start without the "--fork" option. [ec2-user@ip-172-31-29-105 run_dir]$ echo $? 48
Tested on Amazon Linux 2 and 2023 but also seen on RHEL 9 (all on AWS).