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

Calling `shardCollection` after `enableSharding` may fail if executed against different mongos

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.4.10
    • Affects Version/s: 3.2.16, 3.4.9
    • Component/s: Sharding
    • Fully Compatible
    • ALL
    • Sharding 2017-10-02

      The shardCollection command consults a property on the database called sharded. If sharding has not previously been enabled on a database though enableSharding, the shardCollection call will fail.

      If a mongos instance has cached a database entry, there is no mechanism to cause it to refresh it.

      Because of this, if multiple mongos instances have been operating on a given "unsharded" database, enabling sharding on that database will only be reflected on the mongos instance where enableSharding was called and all calls to shardCollection on these instances will continue failing, even though the database has been marked as sharded.

      Since shardCollection is not a frequent operation, it should be made to read the "sharded" property directly from the config server instead of the cache.

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

              Created:
              Updated:
              Resolved: