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

Commands that are unsupported in a transaction should error

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Minor Change
    • Operating System:
      ALL
    • Backport Requested:
      v4.0
    • Sprint:
      Repl 2018-07-02, Repl 2018-07-16, Repl 2018-07-30
    • Linked BF Score:
      0

      Description

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

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                11 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: