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

{shutdown:1} command (always?) fails



    • Type: Bug
    • Status: Open
    • Priority: Minor - P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: None
    • Labels:


      When a client sends


      admin command, the server appears to close the connection on which the command was sent prior to sending a response.

      Shell test:

      ruby-driver-rs:SECONDARY> db.runCommand({shutdown:1})
      2019-09-10T18:03:08.584-0400 E QUERY    [thread1] Error: error doing query: failed: network error while attempting to run command 'shutdown' on host ''  :
      2019-09-10T18:03:08.585-0400 I NETWORK  [thread1] trying reconnect to ( failed
      2019-09-10T18:03:08.585-0400 W NETWORK  [thread1] Failed to connect to, in(checking socket for error after poll), reason: Connection refused
      2019-09-10T18:03:08.585-0400 I NETWORK  [thread1] reconnect ( failed failed 
      2019-09-10T18:03:08.589-0400 I NETWORK  [thread1] trying reconnect to ( failed
      2019-09-10T18:03:08.589-0400 W NETWORK  [thread1] Failed to connect to, in(checking socket for error after poll), reason: Connection refused
      2019-09-10T18:03:08.589-0400 I NETWORK  [thread1] reconnect ( failed failed 

      Ruby driver test:

      irb(main):006:0> c.database.command(shutdown:1)
      D, [2019-09-10T18:00:34.843124 #11418] DEBUG -- : MONGODB | localhost:14440 | admin.shutdown | FAILED | EOFError: end of file reached (for (no TLS)) | 0.004188575s

      Given that the command always fails, it is difficult/impossible for the application trying to shut down a server to verify that the server initiated the shutdown command.

      The command can fail due to being issued against the wrong db for example:

      ruby-driver-rs:SECONDARY> db.runCommand({shutdown:1})
      	"operationTime" : Timestamp(1568152973, 1),
      	"ok" : 0,
      	"errmsg" : "shutdown may only be run against the admin database.",
      	"code" : 13,
      	"codeName" : "Unauthorized",
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1568152973, 1),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)

      This is especially problematic when scripting `mongo` from the Unix shell since simply relying on the exit status of the command does not provide any guarantees as to the success/failure for


      . The driver can inspect precise error message returned and act accordingly, but this requires a fair amount of effort and does not help if there was in fact a network problem during the execution of the command.

      The server should send a successful response to the command and then close the connection (or perform other shutdown-related activities).




            • Votes:
              0 Vote for this issue
              5 Start watching this issue


              • Created: