[SERVER-7893] report fatal startup errors to console on a --fork when possible, Created: 10/Dec/12  Updated: 24/Mar/17  Resolved: 24/Mar/17

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

Type: Improvement Priority: Minor - P4
Reporter: Dwight Merriman Assignee: Unassigned
Resolution: Done Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

for example if the db path doesn't exist, the forked process stops almost immediately, but there is no indication outside the log file specified that this happened. it would be a nice-to-have to get that.

it might be a bit tricky to do this with a universality to it. three approaches? :
1) fork later. then more has happened that could have gone wrong.
2) after forking, have the forking parent wait for a sentinel state from the child either that it is ok or not ok or still in initialization. once out of initialization the parent stops regardless, but perhaps with something to report.
3) just pre-check some very common errors like no data directory – partial solution but trivial to do

this brings up an interesting question of do we want an invocation with --fork to not return until init is completed anyway? i could see some advantages to that. i.e. i might have a script that after starting a mongod then wants to initiate the replica set; but maybe the mongod hasn't even started yet so i have to wait somehow.



 Comments   
Comment by Ian Whalen (Inactive) [ 24/Mar/17 ]

As noted by Andy we already do #2.

Also, milkie has noted that Michał's concern has already been handled in another SERVER ticket.

Comment by Andy Schwerin [ 28/Jun/13 ]

dwight_10gen, we actually already do (2), but do not log to the console once the logfile is open. Maybe extending our existing solution to write to both the log file and the console until initialization succeeds is an appropriate solution? It would be easy to flag-control.

As for mgorny's concern, that appears to be because the server reports to the launching process that all is well before it starts listening on a port. Moving the call to CmdLine::launchOk(), which is the signaling function, might alleviate that problem, today.

Comment by Micha? Górny [ 10/Feb/13 ]

That's almost the same feature I wanted to request. However, in my case the issue is port being occupied — and similarly, mongod seems to start fine but then dies immediately and my script has to grep log to see if it failed.

It should be noted that waiting until the forked process has initialized is a standard practice for forking servers to catch failures during startup. More advanced users definitely expect that.

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