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

Count() can be wrong in sharded collections

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Querying, Sharding
    • Labels:
    • Backwards Compatibility:
      Minor Change
    • Operating System:
      ALL

      Description

      The count command does not ignore orphans like find/queries. This is true whether the query is on the primary or secondaries (which is known to be a different issue).

      For a query like this the count can come back larger if there are orphaned docs, but find will filter them out:

      // more than one shard has the document with x:10, some of which are orphans from migrations
      > coll.count({x:10})
      2
      > coll.find({x:10}).toArray()
      [{_id:10, x:10}]
      > coll.find({x:10}).explain() // some of the explain is removed for brevity
      {
      	"clusteredType" : "ParallelSort",
      	"shards" : { ... },
      	"n" : 1,
      	"nChunkSkips" : 1,
      	"numQueries" : 2,
      	"numShards" : 2,
      	"millis" : 2
      }

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: