[SERVER-6065] db.shutdownServer() does not work as expected when mongod is a Windows Service Created: 11/Jun/12 Updated: 05/Apr/17 Resolved: 10/Feb/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Admin |
| Affects Version/s: | 2.0.6, 2.2.0-rc1, 3.4.0 |
| Fix Version/s: | 3.4.3, 3.5.3 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Ryan Hoffman | Assignee: | Mark Benvenuto |
| Resolution: | Done | Votes: | 9 |
| Labels: | Windows | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows Server 2008 R2 Enterprise |
||
| Issue Links: |
|
||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||
| Operating System: | Windows | ||||||||||||||||||||
| Backport Requested: |
v3.4
|
||||||||||||||||||||
| Sprint: | Platforms 2017-02-13 | ||||||||||||||||||||
| Participants: | |||||||||||||||||||||
| Description |
|
Since the correct way to shutdown a service (net stop mongodb) does not work as expected in 2.0.6, I have attempted to use db.shutdownServer. This unfortionately does not work as expected. Since mongod installs itself with service failure actions to restart the service (love how it does this!), when mongo is shutdown using the shell, Windows seems to think that mongod has exited without the service being shut down, which causes it to automatically restart the service. Sample mongo shell output: ------------------------------------- to: 127.0.0.1 |
| Comments |
| Comment by Githook User [ 28/Feb/17 ] | |||||||||||||||||||||||||||
|
Author: {u'username': u'markbenvenuto', u'name': u'Mark Benvenuto', u'email': u'mark.benvenuto@mongodb.com'}Message: (cherry picked from commit 50e9769099bb49220783f95c9045dd1259a18eb4) | |||||||||||||||||||||||||||
| Comment by Githook User [ 10/Feb/17 ] | |||||||||||||||||||||||||||
|
Author: {u'username': u'markbenvenuto', u'name': u'Mark Benvenuto', u'email': u'mark.benvenuto@mongodb.com'}Message: | |||||||||||||||||||||||||||
| Comment by Itzhak Kagan [ 05/Feb/17 ] | |||||||||||||||||||||||||||
|
This is still occur in 3.4.2 as it reflects in 27782 (a duplicate of this bug) Thanks, | |||||||||||||||||||||||||||
| Comment by Mark Benvenuto [ 20/Jan/17 ] | |||||||||||||||||||||||||||
|
Verified this is still broken on 3.5.2 and 3.4.1. The service stops but incorrectly. It also fails to stop with service stop correctly. Exit stack trace via silent process exit monitoring.
| |||||||||||||||||||||||||||
| Comment by Tad Marshall [ 20/Aug/12 ] | |||||||||||||||||||||||||||
|
This bug will be fixed when | |||||||||||||||||||||||||||
| Comment by Tad Marshall [ 20/Aug/12 ] | |||||||||||||||||||||||||||
|
The issue with "net stop mongodb" is just an unwanted error message ("System error 109 has occurred." and "The pipe has been ended.") and isn't a symptom of anything worse going on. See https://jira.mongodb.org/browse/SERVER-6771 for some information about what is happening. This bug is sort of the flipside of the other one. In Both bugs need basically the same fix. When shutting down while running as a service, we need to return from the "shutdown" code and not exit from it. Once we have unwound through the SCM, including telling it that we have shut down (therefore that we have not "failed"), we are then free to exit the process. Despite the error message that you get from "net stop mongodb", that is probably the better way to shut down MongoDB when it is running as a service (until this ticket is fixed), because we at least tell the Windows Service Control Manager that we are stopped before we exit. With "net stop mongodb" you won't get an error logged to the Windows Event Log and you won't trigger a restart if the service is set to restart on failure. But either way of shutting down is safe and is a clean shutdown from MongoDB's point of view. Journal files will be closed and cleaned up and the mongod.lock files will be truncated, so except for annoying the Windows Service Control Manager everything is fine. Both of these bugs were created when we changed our exit logic to exit immediately after shutting down instead of unwinding through all calling routines and exiting from main() (the way we used to). |