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

Use countDocuments() instead of count() to ensure accurate document count

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 6.0.0-rc0
    • None
    • None
    • None
    • Fully Compatible
    • ALL
    • 15

    Description

      Use "countDocuments" instead of "count" to ensure that we get an accurate count instead of an approximate count from metadata. Otherwise, the count can be inaccurate if a TTL pass happens concurrently with the count call when the access blocker is blocking writes. In this case, the TTL delete will fail and be rolled back, but count calls before the rollback is applied will still reflect the delete.

      see https://github.com/mongodb/mongo/blob/731f87f94d327f83816ae5ef99732e8993d22a92/jstests/replsets/tenant_migration_collection_ttl.js#L80 

      Attachments

        Activity

          People

            christopher.caplinger@mongodb.com Christopher Caplinger
            christopher.caplinger@mongodb.com Christopher Caplinger
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: