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

Provide method for counting orphaned documents

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Sharding
    • Labels:
      None

      Currently, there is not a good way for counting orphaned documents in a sharded cluster.

      The current approach is to run a

      db.collection.find({ShardKey:{$gte: MinKey, $lte: MaxKey}},{ShardKey:1,_id:0}).itcount()
      

      and compare this to the sum of shard counts individually.

      • This query requires a full index scan, streaming the entire results to the shell. This can take significant time to complete on a large sharded cluster.
      • On a busy system these numbers could be off significantly due to inserts and deletes interleaving during the count.
      • Requires multiple queries to multiple hosts, leading to timing errors.

      Since the logic already exists to cleanup orphans, a similar command (or parameter to the existing cleanupOrphaned) to count them would be useful for determining the potential impact of orphans on a given sharded cluster.

            Assignee:
            kelsey.schubert@mongodb.com Kelsey Schubert
            Reporter:
            kevin.arhelger@mongodb.com Kevin Arhelger
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: