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

singleBatch find on a timeseries collection does not close cursor if batchSize is set

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.3.0-rc0
    • Affects Version/s: 7.0.2
    • Component/s: None
    • Query Integration
    • Minor Change
    • ALL
    • Hide
      // Setup TimeSeries collection
      test> db.createCollection('ts', {timeseries: {timeField: 'd'}})
      { ok: 1 }
      test> db.ts.insertOne({d: new Date()})
      { insertedId: ObjectId("652ee0db06dac1dd0b800a19") }
      
      // batchSize
      test> db.runCommand({ find: 'ts', filter: {}, singleBatch: true, batchSize: 1, limit: 1 })
      {
        cursor: {
          firstBatch: [{ ... }],
          id: Long("9141572560536167994"), // non-zero
          ns: 'test.ts'
        },
        ok: 1,
      }
      
      // no batchSize
      test> db.runCommand({ find: 'ts', filter: {}, singleBatch: true, limit: 1 })
      {
        cursor: {
          firstBatch: [{ ... }],
          id: Long("0"), // zero
          ns: 'test.ts'
        },
        ok: 1,
      }
      
      Show
      // Setup TimeSeries collection test> db.createCollection( 'ts' , {timeseries: {timeField: 'd' }}) { ok: 1 } test> db.ts.insertOne({d: new Date()}) { insertedId: ObjectId( "652ee0db06dac1dd0b800a19" ) } // batchSize test> db.runCommand({ find: 'ts' , filter: {}, singleBatch: true , batchSize: 1, limit: 1 }) { cursor: { firstBatch: [{ ... }], id: Long ( "9141572560536167994" ), // non-zero ns: 'test.ts' }, ok: 1, } // no batchSize test> db.runCommand({ find: 'ts' , filter: {}, singleBatch: true , limit: 1 }) { cursor: { firstBatch: [{ ... }], id: Long ( "0" ), // zero ns: 'test.ts' }, ok: 1, }
    • QI 2023-11-27

      When using a TimeSeries collection if a find command has batchSize:1 and singleBatch:true the cursor returned is not closed, it reports a non-zero id. If the batchSize is omitted then the cursor will be closed. The same behavior is not observed for a typical collection, the id returned is always zero when singleBatch is set.

            Assignee:
            will.buerger@mongodb.com Will Buerger
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: