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

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Catalog
    • None
    • Storage Execution

      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();
      

            Assignee:
            backlog-server-execution [DO NOT USE] Backlog - Storage Execution Team
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: