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

Support getMore on snapshot cursor even after unrelated index is created or dropped

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Duplicate
    • None
    • None
    • Catalog
    • None
    • Storage Execution

    Description

      Creating or dropping an index raises the collection's minimum visible snapshot. This causes a getMore on a snapshot cursor to return a SnapshotUnavailable error response, even if it wouldn't use that index. Longer-running snapshot reads would be more useful if their query plan wasn't impacted by the change to the collection's minimum visible snapshot.

      const rst = new ReplSetTest({nodes: 1});
      rst.startSet();
      rst.initiate();
       
      const db = rst.getPrimary().getDB("test");
      assert.commandWorked(db.mycoll.insert(Array.from({length: 5}, (_, i) => ({_id: i}))));
      const cursor = db.mycoll.find().readConcern("snapshot").batchSize(1);
       
      assert.eq({_id: 0}, cursor.next());
      assert.eq({_id: 1}, cursor.next());
      assert.commandWorked(db.mycoll.createIndex({a: 1}));
      // HERE: The getMore command fails with SnapshotUnavailable due to the collection's minimum visible
      // snapshot being bumped from creating the {a: 1} index.
      assert.eq({_id: 2}, cursor.next());
       
      rst.stopSet();
      

      Attachments

        Issue Links

          Activity

            People

              backlog-server-execution Backlog - Storage Execution Team
              max.hirschhorn@mongodb.com Max Hirschhorn
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: