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

Wrong initial chunk owner shard can be selected when sharding non-empty collection with pre-created zones

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Critical - P2 Critical - P2
    • 4.0.6, 4.1.8
    • Affects Version/s: 4.0.5
    • Component/s: Sharding
    • Fully Compatible
    • ALL
    • v4.0
    • Sharding 2019-01-28, Sharding 2019-02-11

      Issue Status as of Jan 30, 2019

      ISSUE DESCRIPTION AND IMPACT
      If a user specifies zones for a non-empty collection prior to sharding it, there is a chance that the initial chunk will be placed onto an incorrect shard, thus effectively losing all the documents in the sharded collection. This will occur if there is more than one shard (e.g. shard01, shard02) and the database's primary is not the first alphabetically-sorted shard (e.g. shard02 in the example above).

      DIAGNOSIS AND AFFECTED VERSIONS
      Only MongoDB 4.0.5 is affected. Prior to MongoDB 4.0.5, it was not possible to shard a non-empty collection with zones preset.

      REMEDIATION AND WORKAROUNDS
      Users running MongoDB 4.0.5 are strongly encouraged to upgrade to 4.0.6 or later immediately. If an immediate upgrade is not possible, users should ensure that no zones are set for a non-empty collection before sharding it. After sharding a non-empty collection, the zones can be safely set.

      FIXED VERSIONS
      The fix is included in MongoDB 4.0.6.

      Original description

      When sharding a non-empty collection, whose primary is not the first alphabetically-sorted shard, the Fast Initial Split logic can select wrong shard for the lone initial chunk.

      These are the conditions for this issue to occur:

      • There is more than one shard (e.g., shard01, shard02)
      • The database's primary is not the first alphabetically-sorted shard (shard02 in the example above)
      • There are some zones defined for the collection (so the Fast Initial Split optimization is attempted)
      • The unsharded collection contains some documents (so that the Fast Initial Split optimization won't kick-in)

      In this case, attempting to shard such a collection will wrongly place the only chunk on the first alphabetically-sorted shard, which means none of the documents for that collection will be visible anymore.

            Assignee:
            kaloian.manassiev@mongodb.com Kaloian Manassiev
            Reporter:
            kaloian.manassiev@mongodb.com Kaloian Manassiev
            Votes:
            0 Vote for this issue
            Watchers:
            26 Start watching this issue

              Created:
              Updated:
              Resolved: