Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-2184

estimatedDocumentCount should use count command for 5.0.x + not-stable API

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Component/s: None
    • None
    • Needed

      Summary

      The MongoDB drivers implementation for the estimatedDocumentCount helper changed for 5.0.x+ from using the count command to aggregate with a $collStats stage. This resulted in a change in behavior, where this helper will no longer provide a fallback from the estimate to an accurate/slow collection count. The means that users can no longer use this helper to determine the document count for a view. We would like to restore the previous behavior for users of 5.0.x+ when they are not using the stable API.

      Note that we expect to make a follow up change for 6.0+ to use a new $approxCount stage under DRIVERS-1982.

      Motivation

      Who is the affected end user?

      SERVER-59674 tracks affected end users. Currently this includes a small number of internal and external users.

      How does this affect the end user?

      Users who use the estimatedDocumentCount helper to determine the count for a view will encounter an error rather than receive an accurate/slow count.

      How likely is it that this problem or use case will occur?

      Users of estimatedDocumentCount and non-materialized views will encounter this issue.

      If the problem does occur, what are the consequences and how severe are they?

      This has the potential to break a user application on server+driver upgrade to 5.0. To work around without this change, they would need swap usage of this helper with a count command invocation.

      Is this issue urgent?

      No required timeline but as this impacts any users who upgrade to 5.0 we should look to expedite if possible.

      Is this ticket required by a downstream team?

      Both Atlas and Data Explorer teams were impacted by this. I believe both have worked around, but may be interested in knowing that this is available.

      Is this ticket only for tests?

      No

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            james.wahlin@mongodb.com James Wahlin
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: