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

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

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.0
    • Steps To Reproduce:
      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(); })();
    • Sprint:
      TIG 2018-06-04
    • Linked BF Score:
      0

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              max.hirschhorn Max Hirschhorn
              Reporter:
              daniel.gottlieb Daniel Gottlieb
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: