[SERVER-5651] Better implementation of Windows server shutdown Created: 19/Apr/12  Updated: 11/Jul/16  Resolved: 31/Dec/13

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: 2.0.4
Fix Version/s: 2.5.5

Type: Improvement Priority: Critical - P2
Reporter: Eric Milkie Assignee: Mark Benvenuto
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows


Issue Links:
Duplicate
duplicates SERVER-12443 Skip mongos_rs_shard_failure_toleranc... Closed
is duplicated by SERVER-5024 Fix shutdown method on ShardingTest t... Closed
Related
is related to SERVER-5405 mongos does not send reads to seconda... Closed
Backwards Compatibility: Fully Compatible
Participants:

 Description   

Currently, StopMongoProgram() in shell_utils_launcher.cpp sends a SIGTERM on Linux, which shuts down the database cleanly.
On Windows, it actually connects to the database and attempts to issue a shutdown command. This can fail in a bunch of ways, and when that happens the shell calls TerminateProcess(), which shuts down the server uncleanly. This becomes a problem in unit tests where we need to be able to shut down the server cleanly and start it up again.

One way to improve this situation is to use Events. These can have the same semantics as UNIX signals; the main difference is that on Windows, you need to explicitly set up a listener ahead of time.

So in mongod, we will have a new thread that just calls CreateEvent() and then blocks in WaitForSingleObject(). After it unblocks, it simply calls dbexit().

In the shell, in the implementation of stopMongoProgram(), it will call OpenEvent() to open the same event that the mongod created and then call SetEvent() to signal it.



 Comments   
Comment by Githook User [ 02/Jan/14 ]

Author:

{u'username': u'markbenvenuto', u'name': u'Mark Benvenuto', u'email': u'mark.benvenuto@mongodb.com'}

Message: SERVER-5651: Better implementation of Windows server shutdown
Branch: master
https://github.com/mongodb/mongo/commit/b4caa84a9f8a49ccafae06730b9e0087dbbfbb92

Comment by Githook User [ 31/Dec/13 ]

Author:

{u'username': u'markbenvenuto', u'name': u'Mark Benvenuto', u'email': u'mark.benvenuto@mongodb.com'}

Message: SERVER-5651: Better implementation of Windows server shutdown
Branch: master
https://github.com/mongodb/mongo/commit/ffe170ed99cbb04918e75ebbee408871a810123a

Comment by Randolph Tan [ 19/Apr/12 ]

One example of a failure scenario is when the mongod is authenticated and since the shutdown command requires admin priviledge, stopMongod won't be able to shut the server down with anything other than SIG_KILL.

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