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

`dbHash` can take locks in MODE_S while in a transaction

    • Fully Compatible
    • ALL
    • v4.0
    • Hide
      (function() {
          let rst = new ReplSetTest({nodes: 1});
          rst.startSet();
          rst.initiate();
      
          rst.getPrimary().getDB("test").foo.insert({});
      
          var sess = rst.getPrimary().startSession({causalConsistency: false});
          sess.startTransaction();
          sess.getDatabase("test").runCommand({dbHash: 1});
          sess.getDatabase("test").foo.find().next();
      })();
      
      Show
      (function() { let rst = new ReplSetTest({nodes: 1}); rst.startSet(); rst.initiate(); rst.getPrimary().getDB("test").foo.insert({}); var sess = rst.getPrimary().startSession({causalConsistency: false}); sess.startTransaction(); sess.getDatabase("test").runCommand({dbHash: 1}); sess.getDatabase("test").foo.find().next(); })();
    • TIG 2018-06-04
    • 0

      SERVER-34778 allowed dbHash to be run inside of a multi-statement transaction. Multi-statement transactions convert all lock acquisition of database and collection locks to be MODE_IX (a higher level is used for determining whether the operation may be performed in a transaction).

      However, the dbHash only performs lock conversion if the command specifies an atClusterTime as part of its read concern.

      Thus a client can now:

      1. Start a transaction
      2. Perform a DBHash without using atClusterTime, taking a MODE_S lock on each database
      3. Perform a CRUD operation which is converted to MODE_IX

      The server will crash on the CRUD operation when this invariant fires, noticing the MODE_IX request while the operation context already holds the lock in MODE_S.

            Assignee:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Reporter:
            daniel.gottlieb@mongodb.com Daniel Gottlieb (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: