After upgrading MongoDB from 4.2 to 8.0, the count query cannot return results.

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: 8.0.28
    • Component/s: None
    • None
    • ALL
    • Hide

      8.0.28:-- no longer returns results and gets stuck.
      [direct: mongos] outMonitor> db.monitorOut.count({ct:{$gte:ISODate("2026-08-19T00:00:00"),$lt:ISODate("2026-08-20T00:00:00")}})
      DeprecationWarning: Collection.count() is deprecated. Use countDocuments or estimatedDocumentCount.
      wait 30m --can't return result
      {
      shard: 'shard7',
      type: 'op',
      desc: 'conn276941',
      connectionId: 276941,
      appName: 'mongosh 2.5.2',
      clientMetadata: {
      application:

      { name: 'mongosh 2.5.2' }

      ,
      driver:

      { name: 'nodejs|mongosh', version: '6.16.0|2.5.2' }

      ,
      platform: 'Node.js v20.19.2, LE',
      os:

      { name: 'linux', architecture: 'x64', version: '3.10.0-327.22.2.el7.x86_64', type: 'Linux' }

      ,
      mongos:

      { client: 'anonymous unix socket:27017', version: '8.0.28' }

      },
      active: true,
      currentOpTime: '2026-09-02T11:54:26.500+08:00',
      effectiveUsers: [

      { user: 'admin', db: 'admin' }

      ],
      runBy: [

      { user: '__system', db: 'local' }

      ],
      isFromUserConnection: true,
      threaded: true,
      opid: 'shard7:780952580',
      lsid:

      { id: UUID('4e7e96f2-317a-49a0-a274-4585d5e531fe'), uid: Binary.createFromBase64('O0CMtIVItQN4IsEOsJdrPL8s7jv5xwh5a/A5Qfvs2A8=', 0) }

      ,
      secs_running: Long('2717'),
      microsecs_running: Long('2717087426'),
      op: 'command',
      ns: 'outMonitor.monitorOut',
      redacted: false,
      command: {
      explain: {
      find: 'monitorOut',
      filter: {
      ct:

      { '$gte': ISODate('2026-08-19T00:00:00.000Z'), '$lt': ISODate('2026-08-20T00:00:00.000Z') }

      }
      },
      verbosity: 'executionStats',
      readConcern:

      { level: 'local', provenance: 'implicitDefault' }

      ,
      shardVersion: {
      e: ObjectId('6a858b7c4bb33126ec6459ce'),
      t: Timestamp(

      { t: 1787136892, i: 19 }

      ),
      v: Timestamp(

      { t: 29706, i: 2 }

      )
      },
      lsid:

      { id: UUID('4e7e96f2-317a-49a0-a274-4585d5e531fe'), uid: Binary.createFromBase64('O0CMtIVItQN4IsEOsJdrPL8s7jv5xwh5a/A5Qfvs2A8=', 0) }

      ,
      '$clusterTime': { clusterTime: Timestamp(

      { t: 1788318544, i: 1 }

      ) },
      '$configTime': Timestamp(

      { t: 1788318544, i: 1 }

      ),
      '$topologyTime': Timestamp(

      { t: 1787014773, i: 10 }

      ),
      '$audit': {
      '$impersonatedUser':

      { user: 'admin', db: 'admin' }

      ,
      '$impersonatedRoles': [

      { role: 'root', db: 'admin' }

      ]
      },
      '$client': {
      application:

      { name: 'mongosh 2.5.2' }

      ,
      driver:

      { name: 'nodejs|mongosh', version: '6.16.0|2.5.2' }

      ,
      platform: 'Node.js v20.19.2, LE',
      os:

      { name: 'linux', architecture: 'x64', version: '3.10.0-327.22.2.el7.x86_64', type: 'Linux' }

      ,
      mongos:

      { host: 'srvmid1670.yto.cloud:21051', client: 'anonymous unix socket:27017', version: '8.0.28' }

      },
      mayBypassWriteBlocking: true,
      '$db': 'outMonitor'
      },
      queryFramework: 'classic',
      numYields: 16846,
      numInterruptChecks: Long('33697'),
      queues: {
      execution:

      { admissions: 16847, totalTimeQueuedMicros: Long('0') }

      ,
      ingress:

      { admissions: 1, totalTimeQueuedMicros: Long('0') }

      },
      currentQueue: null,
      locks:

      { Global: 'r' }

      ,
      waitingForLock: false,
      lockStats: {
      Global: { acquireCount:

      { r: Long('16847') }

      },
      Mutex: { acquireCount:

      { r: Long('3') }

      }
      },
      waitingForFlowControl: false,
      flowControlStats: {}
      }

      4.2.12:
      mongos> db.monitorOut.count({ct:{$gte:ISODate("2026-08-19T00:00:00"),$lt:ISODate("2026-08-20T00:00:00")}})
      86954105

      5m can return result

      Show
      8.0.28:-- no longer returns results and gets stuck. [direct: mongos] outMonitor> db.monitorOut.count({ct:{$gte:ISODate("2026-08-19T00:00:00"),$lt:ISODate("2026-08-20T00:00:00")}}) DeprecationWarning: Collection.count() is deprecated. Use countDocuments or estimatedDocumentCount. wait 30m --can't return result { shard: 'shard7', type: 'op', desc: 'conn276941', connectionId: 276941, appName: 'mongosh 2.5.2', clientMetadata: { application: { name: 'mongosh 2.5.2' } , driver: { name: 'nodejs|mongosh', version: '6.16.0|2.5.2' } , platform: 'Node.js v20.19.2, LE', os: { name: 'linux', architecture: 'x64', version: '3.10.0-327.22.2.el7.x86_64', type: 'Linux' } , mongos: { client: 'anonymous unix socket:27017', version: '8.0.28' } }, active: true, currentOpTime: '2026-09-02T11:54:26.500+08:00', effectiveUsers: [ { user: 'admin', db: 'admin' } ], runBy: [ { user: '__system', db: 'local' } ], isFromUserConnection: true, threaded: true, opid: 'shard7:780952580', lsid: { id: UUID('4e7e96f2-317a-49a0-a274-4585d5e531fe'), uid: Binary.createFromBase64('O0CMtIVItQN4IsEOsJdrPL8s7jv5xwh5a/A5Qfvs2A8=', 0) } , secs_running: Long('2717'), microsecs_running: Long('2717087426'), op: 'command', ns: 'outMonitor.monitorOut', redacted: false, command: { explain: { find: 'monitorOut', filter: { ct: { '$gte': ISODate('2026-08-19T00:00:00.000Z'), '$lt': ISODate('2026-08-20T00:00:00.000Z') } } }, verbosity: 'executionStats', readConcern: { level: 'local', provenance: 'implicitDefault' } , shardVersion: { e: ObjectId('6a858b7c4bb33126ec6459ce'), t: Timestamp( { t: 1787136892, i: 19 } ), v: Timestamp( { t: 29706, i: 2 } ) }, lsid: { id: UUID('4e7e96f2-317a-49a0-a274-4585d5e531fe'), uid: Binary.createFromBase64('O0CMtIVItQN4IsEOsJdrPL8s7jv5xwh5a/A5Qfvs2A8=', 0) } , '$clusterTime': { clusterTime: Timestamp( { t: 1788318544, i: 1 } ) }, '$configTime': Timestamp( { t: 1788318544, i: 1 } ), '$topologyTime': Timestamp( { t: 1787014773, i: 10 } ), '$audit': { '$impersonatedUser': { user: 'admin', db: 'admin' } , '$impersonatedRoles': [ { role: 'root', db: 'admin' } ] }, '$client': { application: { name: 'mongosh 2.5.2' } , driver: { name: 'nodejs|mongosh', version: '6.16.0|2.5.2' } , platform: 'Node.js v20.19.2, LE', os: { name: 'linux', architecture: 'x64', version: '3.10.0-327.22.2.el7.x86_64', type: 'Linux' } , mongos: { host: 'srvmid1670.yto.cloud:21051', client: 'anonymous unix socket:27017', version: '8.0.28' } }, mayBypassWriteBlocking: true, '$db': 'outMonitor' }, queryFramework: 'classic', numYields: 16846, numInterruptChecks: Long('33697'), queues: { execution: { admissions: 16847, totalTimeQueuedMicros: Long('0') } , ingress: { admissions: 1, totalTimeQueuedMicros: Long('0') } }, currentQueue: null, locks: { Global: 'r' } , waitingForLock: false, lockStats: { Global: { acquireCount: { r: Long('16847') } }, Mutex: { acquireCount: { r: Long('3') } } }, waitingForFlowControl: false, flowControlStats: {} } 4.2.12: mongos> db.monitorOut.count({ct:{$gte:ISODate("2026-08-19T00:00:00"),$lt:ISODate("2026-08-20T00:00:00")}}) 86954105 5m can return result
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      After upgrading and expanding a sharded cluster from 6 shards on MongoDB 4.2 to 12 shards on MongoDB 8.0, a count query on a one-day time range no longer returns results and gets stuck. This query had been fast on the original 4.2 cluster. query using ct index。
      db.monitorOut.count({ct:{$gte:ISODate("2026-08-19T00:00:00"),$lt:ISODate("2026-08-20T00:00:00")}})

            Assignee:
            Benjamin Ulmer
            Reporter:
            jing xu (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: