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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 6.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • 15
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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 

            Assignee:
            Christopher Caplinger
            Reporter:
            Christopher Caplinger
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: