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

{shutdown:1} command (always?) fails

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Do
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Service Arch
    • Service Arch 2019-09-23, Service Arch 2019-10-07

      When a client sends

      {shutdown:1}

      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 '127.0.0.1:30201'  :
      DB.prototype.runCommand@src/mongo/shell/db.js:168:1
      @(shell):1:1
      2019-09-10T18:03:08.585-0400 I NETWORK  [thread1] trying reconnect to 127.0.0.1:30201 (127.0.0.1) failed
      2019-09-10T18:03:08.585-0400 W NETWORK  [thread1] Failed to connect to 127.0.0.1:30201, in(checking socket for error after poll), reason: Connection refused
      2019-09-10T18:03:08.585-0400 I NETWORK  [thread1] reconnect 127.0.0.1:30201 (127.0.0.1) failed failed 
      2019-09-10T18:03:08.589-0400 I NETWORK  [thread1] trying reconnect to 127.0.0.1:30201 (127.0.0.1) failed
      2019-09-10T18:03:08.589-0400 W NETWORK  [thread1] Failed to connect to 127.0.0.1:30201, in(checking socket for error after poll), reason: Connection refused
      2019-09-10T18:03:08.589-0400 I NETWORK  [thread1] reconnect 127.0.0.1:30201 (127.0.0.1) 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 127.0.0.1:14440 (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)
      		}
      	}
      }
      ruby-driver-rs:SECONDARY> 
      

      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

      {shutdown:1}

      . 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).

            Assignee:
            backlog-server-servicearch [DO NOT USE] Backlog - Service Architecture
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: