[SERVER-27742] Do not crash if parent goes missing after fork Created: 18/Jan/17  Updated: 06/Dec/22  Resolved: 18/Aug/20

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

Type: Bug Priority: Major - P3
Reporter: Eric Milkie Assignee: Backlog - Service Architecture
Resolution: Incomplete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Assigned Teams:
Service Arch
Operating System: ALL
Steps To Reproduce:

Start a mongod with --fork and induce a long startup time (e.g., WiredTiger or mmap with a lot of journal recovery work to do, or many collections to open and inspect, etc.). Kill the parent process prior to the fork completing, and note that the child mongod will abort with the above message.

Participants:
Case:

 Description   

If the parent process goes away before the child has a chance to complete initialization, the mongod process will shut down when it tries to send signal USR2 to the parent, indicating that startup is complete. (function signalForkSuccess()).
It also dies with an unfriendly message:

2016-10-05T09:22:25.215+0000 I -        [initandlisten] Assertion failure kill(serverGlobalParams.leaderProc.toNative(), 12) == 0 src/mongo/db/initialize_server_global_state.cpp 95

I see no reason to crash if the parent process is missing. Instead, I think we should just log a warning and continue starting up.



 Comments   
Comment by 海波 尹 [ 02/Dec/20 ]

If you have this problem, please check you MongoDB log rotate task first.

While you send SIGUSR1 which is a log rotate signal to MongoDB process, the parent process will be terminated. So this problem will be occur. 

So, Close you log rotate task while you need a long time to restore you MongoDB.

Comment by Benjamin Caimano (Inactive) [ 18/Aug/20 ]

We think this is currently functioning as we would expect.

Comment by Eric Milkie [ 22/Jan/17 ]

That's not even a valid assumption today. But i'm fine with just making the error message more friendly when this situation occurs.

Comment by Andy Schwerin [ 22/Jan/17 ]

Imagine your startup script assumes that mongod crashed when it exits with
a non-zero code...

Comment by Eric Milkie [ 20/Jan/17 ]

I'm not sure. The parent process can only really go away by being killed, right? Assuming there are no bugs. So if something killed the parent process on purpose (perhaps with SIGHUP because the network connection went away), I'm not sure the expected behavior is that the forked process would go away too. Certainly the user in the linked support ticket did not expect that behavior, but they also weren't aware of the parent being killed, I suspect.

Comment by Andy Schwerin [ 19/Jan/17 ]

If the parent process is gone, it will have exited with a non-zero code. As
such, won't the caller expect the server to shut down?

Generated at Thu Feb 08 04:16:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.