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

Commands that are unsupported in a transaction should error

    • Minor Change
    • ALL
    • v4.0
    • Repl 2018-07-02, Repl 2018-07-16, Repl 2018-07-30
    • 0

      This isMaster and ping commands (and possibly others) are not supported in a transaction but the server does not report an error when they are run within one.

      > client = db.getMongo()
      connection to 127.0.0.1:27017
      > session = client.startSession()
      > session.startTransaction()
      > session.getDatabase("admin").runCommand('isMaster')
      {
      	"hosts" : "..."
      }
      > session.commitTransaction()
      assert: command failed: {
      	"operationTime" : Timestamp(1524616281, 1),
      	"ok" : 0,
      	"errmsg" : "Given transaction number 1 does not match any in-progress transactions.",
      	"code" : 251,
      	"codeName" : "NoSuchTransaction",
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1524616281, 1),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      }
      _getErrorWithCode@src/mongo/shell/utils.js:25:13
      doassert@src/mongo/shell/assert.js:16:14
      _assertCommandWorked@src/mongo/shell/assert.js:510:17
      assert.commandWorked@src/mongo/shell/assert.js:594:16
      commitTransaction@src/mongo/shell/session.js:848:17
      @(shell):1:1
      
      2018-04-24T17:31:23.262-0700 E QUERY    [js] Error: command failed: {
      	"operationTime" : Timestamp(1524616281, 1),
      	"ok" : 0,
      	"errmsg" : "Given transaction number 1 does not match any in-progress transactions.",
      	"code" : 251,
      	"codeName" : "NoSuchTransaction",
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1524616281, 1),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      } :
      _getErrorWithCode@src/mongo/shell/utils.js:25:13
      doassert@src/mongo/shell/assert.js:16:14
      _assertCommandWorked@src/mongo/shell/assert.js:510:17
      assert.commandWorked@src/mongo/shell/assert.js:594:16
      commitTransaction@src/mongo/shell/session.js:848:17
      @(shell):1:1
      

      Expected behavior: the isMaster should error because it's not supported in a transaction. For example:

      > session.startTransaction()
      > session.getDatabase("admin").runCommand('isMaster')
      {
      	"operationTime" : Timestamp(1524616521, 1),
      	"ok" : 0,
      	"errmsg" : "Cannot run 'isMaster' in a multi-document transaction.",
      	"code" : 50767,
      	"codeName" : "Location50767",
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1524616521, 1),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      }
      

            Assignee:
            tess.avitabile@mongodb.com Tess Avitabile (Inactive)
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: