Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-5651

Better implementation of Windows server shutdown

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 2.5.5
    • Affects Version/s: 2.0.4
    • Component/s: Testing Infrastructure
    • None
    • Environment:
      Windows
    • Fully Compatible

      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.

            Assignee:
            mark.benvenuto@mongodb.com Mark Benvenuto
            Reporter:
            milkie@mongodb.com Eric Milkie
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: