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

db.shutdownServer() does not work as expected when mongod is a Windows Service

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.4.3, 3.5.3
    • Affects Version/s: 2.0.6, 2.2.0-rc1, 3.4.0
    • Component/s: Admin
    • Labels:
    • Environment:
      Windows Server 2008 R2 Enterprise
    • Fully Compatible
    • Windows
    • v3.4
    • Platforms 2017-02-13

      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:

      -------------------------------------
      SECONDARY> db.serverStatus().uptime
      531
      SECONDARY> use admin
      switched to db admin
      SECONDARY> db.shutdownServer()
      Mon Jun 11 11:07:09 DBClientCursor::init call() failed
      Mon Jun 11 11:07:09 query failed : admin.$cmd

      { shutdown: 1.0 }

      to: 127.0.0.1
      server should be down...
      Mon Jun 11 11:07:09 trying reconnect to 127.0.0.1
      Mon Jun 11 11:07:10 reconnect 127.0.0.1 ok
      SECONDARY> db.serverStatus().uptime
      4
      -------------------------------------

            Assignee:
            mark.benvenuto@mongodb.com Mark Benvenuto
            Reporter:
            rhoffman Ryan Hoffman
            Votes:
            9 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: