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

AutoGetCollectionForRead should throw with SnapshotUnavailable if provided timestamp is earlier than minimum visible snapshot

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.10
    • Affects Version/s: None
    • Component/s: Replication
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Hide
      //
      // Run with: python buildscripts/resmoke.py --suites=jstestfuzz_replication_session repro.js
      //
      
      res = db.test.runCommand("insert", {
          documents :[{x:1}]
      });
      let operTime = res.operationTime;
      
      // Works.
      res = db.runCommand({
          find: "test",
          sort: {_id: 1},
          $_internalReadAtClusterTime: operTime,
      });
      assert.commandWorked(res);
      
      // Causes invariant failure.
      res = db.runCommand({
          find: "test",
          sort: {_id: 1},
          $_internalReadAtClusterTime: Timestamp(operTime.getTime()-1, operTime.getInc()),
      });
      
      Show
      // // Run with : python buildscripts/resmoke.py --suites=jstestfuzz_replication_session repro.js // res = db.test.runCommand( "insert" , { documents :[{x:1}] }); let operTime = res.operationTime; // Works. res = db.runCommand({ find: "test" , sort: {_id: 1}, $_internalReadAtClusterTime: operTime, }); assert.commandWorked(res); // Causes invariant failure. res = db.runCommand({ find: "test" , sort: {_id: 1}, $_internalReadAtClusterTime: Timestamp(operTime.getTime()-1, operTime.getInc()), });
    • Repl 2019-03-25, Repl 2019-04-08
    • 53

      Since the addition of the $_internalReadAtClusterTime field in SERVER-39169, it is possible for a 'find' command to do a read at a timestamp specified by the client. This means that when taking locks inside the AutoGetCollectionForRead constructor it is possible to be using a kProvided read source where the given timestamp is earlier than the minimum visible snapshot for the collection. If this is the case, then we will run past this logic and continue on to trigger this invariant. Instead of triggering an invariant in this case, we should throw an exception with a SnapshotUnavailable error, analogous to the behavior of dbHash command.

            Assignee:
            william.schultz@mongodb.com William Schultz (Inactive)
            Reporter:
            william.schultz@mongodb.com William Schultz (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: