Fix listDatabases command filter in cluster_list_databases_cmd.cpp

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Catalog and Routing
    • ALL
    • CAR Team 2026-03-30, CAR Team 2026-04-13
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Currently, when a listDatabases command includes a filter, the filter is forwarded to individual shards but is not re-applied to the aggregated result on mongos. This can produce incorrect results in several scenarios:

      • sizeOnDisk: A filter on sizeOnDisk is evaluated per shard, but the aggregated sizeOnDisk (summed across shards) may differ from any individual shard's value. A database that correctly passes the filter on each shard individually could fail (or incorrectly pass) the filter when evaluated against the aggregated total.
      • shards: The shards property exists only in the aggregated mongos result — it does not exist in individual shard responses. As a result, any filter referencing shards will cause matching entries to be skipped, since the field is absent at the shard level.
      • empty: The empty property is calculated differently on mongod vs. mongos.

      To fix it, a filter has to be applied to the aggregated result on mongos.

      Also, along with the fix, the full coverage tests have to be added for various filter cases and combinations.

            Assignee:
            Igor Praznik
            Reporter:
            Igor Praznik
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: