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

Difference in behavior of $_resumeAfter between classic and SBE engines

    • Query Execution
    • Fully Compatible
    • ALL
    • v7.2, v7.0
    • Hide
      > db.u.drop()
      > db.u.insertMany([{x:1}, {x:2}])
      > db.runCommand({find: "u", batchSize: 1, $_requestResumeToken: true, hint:  {$natural:1}})
      // it will return a resume token with {"$recordId" : NumberLong(1)}
      > db.runCommand({find: "u", batchSize: 1, $_requestResumeToken: true, hint:  {$natural:1}, $_resumeAfter: {"$recordId" : NumberLong(1)}})
      // it will return a resume token with {"$recordId" : NumberLong(2)} -- the last record in the collection
      
      > db.adminCommand({setParameter: 1, internalQueryFrameworkControl: "trySbeEngine"})
      > db.runCommand({find: "u", batchSize: 1, $_requestResumeToken: true, hint:  {$natural:1}, $_resumeAfter: {"$recordId" : NumberLong(2)}})
      {
              "cursor" : {
                      "firstBatch" : [ ],
                      "postBatchResumeToken" : {
                              "$recordId" : NumberLong(2)
                      },
                      "id" : NumberLong(0),
                      "ns" : "my.u"
              },
              "ok" : 1
      }
      
      > db.adminCommand({setParameter: 1, internalQueryFrameworkControl: "forceClassicEngine"})
      > db.runCommand({find: "u", batchSize: 1, $_requestResumeToken: true, hint:  {$natural:1}, $_resumeAfter: {"$recordId" : NumberLong(2)}})
      {
              "cursor" : {
                      "firstBatch" : [ ],
                      "postBatchResumeToken" : {
                              "$recordId" : null
                      },
                      "id" : NumberLong(0),
                      "ns" : "my.u"
              },
              "ok" : 1
      }
      
      Show
      > db.u.drop() > db.u.insertMany([{x:1}, {x:2}]) > db.runCommand({find: "u" , batchSize: 1, $_requestResumeToken: true , hint: {$natural:1}}) // it will return a resume token with { "$recordId" : NumberLong(1)} > db.runCommand({find: "u" , batchSize: 1, $_requestResumeToken: true , hint: {$natural:1}, $_resumeAfter: { "$recordId" : NumberLong(1)}}) // it will return a resume token with { "$recordId" : NumberLong(2)} -- the last record in the collection > db.adminCommand({setParameter: 1, internalQueryFrameworkControl: "trySbeEngine" }) > db.runCommand({find: "u" , batchSize: 1, $_requestResumeToken: true , hint: {$natural:1}, $_resumeAfter: { "$recordId" : NumberLong(2)}}) { "cursor" : { "firstBatch" : [ ], "postBatchResumeToken" : { "$recordId" : NumberLong(2) }, "id" : NumberLong(0), "ns" : "my.u" }, "ok" : 1 } > db.adminCommand({setParameter: 1, internalQueryFrameworkControl: "forceClassicEngine" }) > db.runCommand({find: "u" , batchSize: 1, $_requestResumeToken: true , hint: {$natural:1}, $_resumeAfter: { "$recordId" : NumberLong(2)}}) { "cursor" : { "firstBatch" : [ ], "postBatchResumeToken" : { "$recordId" : null }, "id" : NumberLong(0), "ns" : "my.u" }, "ok" : 1 }
    • QE 2023-11-13, QE 2023-11-27
    • 138

      When resuming from the last record in a collection, the classic engine returns resume token {"$recordId" : null} and SBE returns the last record.
      Resuming from {"$recordId" : null} in the classic record cycles back to the start of the collection and raises "KeyNotFound" error in SBE.

            Assignee:
            mihai.andrei@mongodb.com Mihai Andrei
            Reporter:
            irina.yatsenko@mongodb.com Irina Yatsenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            21 Start watching this issue

              Created:
              Updated:
              Resolved: