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

$shardedDataDistribution should not show orphans in recipient shard

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Catalog and Routing

      Steps to repro: 

      • Start a data migration from shard-0 to an empty shard-1 using chunk migrations. 
      • run $shardedDataDistribution while the migration is ongoing

      The $shardedDataDistribution output shows orphan count on shard-1. Orphans are documents not owned by a shard so it is probably showing the doc count that is not yet owned by shard-1. However, this is confusing because orphans are created on the donor shard so one would expect to only see orphans on shard-0. 

      It is worth investigating if we should show orphans only for donor shard. 

       

      db.aggregate([{$shardedDataDistribution: {}}, {$match: {ns: "testdb.biggie"}}] )
      [
        {
          ns: 'testdb.biggie',
          shards: [
            {
              shardName: 'atlas-2nqu8t-shard-0',
              numOrphanedDocs: 128879333,
              numOwnedDocuments: 832508835,
              ownedSizeBytes: Long('963212722095'),
              orphanedSizeBytes: Long('149113388281')
            },
            {
              shardName: 'atlas-2nqu8t-shard-1',
              numOrphanedDocs: 57690,
              numOwnedDocuments: 145822363,
              ownedSizeBytes: Long('168716473991'),
              orphanedSizeBytes: 66747330
            }
          ]
        }
      ]
      Atlas [mongos] admin> db.aggregate([{$shardedDataDistribution: {}}] )
      [
        {
          ns: 'config.system.sessions',
          shards: [
            {
              shardName: 'atlas-2nqu8t-shard-0',
              numOrphanedDocs: 0,
              numOwnedDocuments: 226,
              ownedSizeBytes: 31188,
              orphanedSizeBytes: 0
            }
          ]
        },
        {
          ns: 'testdb.biggie',
          shards: [
            {
              shardName: 'atlas-2nqu8t-shard-0',
              numOrphanedDocs: 128879333,
              numOwnedDocuments: 832504886,
              ownedSizeBytes: Long('963208153102'),
              orphanedSizeBytes: Long('149113388281')
            },
            {
              shardName: 'atlas-2nqu8t-shard-1',
              numOrphanedDocs: 72113,
              numOwnedDocuments: 145818651,
              ownedSizeBytes: Long('168712179207'),
              orphanedSizeBytes: 83434741
            }
          ]
        }
      ] 

      Orphan definition in our docs: 

      In a sharded cluster, orphaned documents are those documents on a shard that also exist in chunks on other shards. This is caused by a failed migration or an incomplete migration cleanup because of an atypical shutdown.

      Orphaned documents are cleaned up automatically after a chunk migration completes.

            Assignee:
            Unassigned Unassigned
            Reporter:
            ratika.gandhi@mongodb.com Ratika Gandhi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: