[SERVER-31204] Calling `shardCollection` after `enableSharding` may fail if executed against different mongos Created: 21/Sep/17  Updated: 30/Oct/23  Resolved: 22/Sep/17

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 3.2.16, 3.4.9
Fix Version/s: 3.4.10

Type: Bug Priority: Major - P3
Reporter: Kaloian Manassiev Assignee: Kaloian Manassiev
Resolution: Fixed Votes: 1
Labels: SWCW
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Sharding 2017-10-02
Participants:
Case:

 Description   

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.



 Comments   
Comment by Githook User [ 22/Sep/17 ]

Author:

{'email': 'kaloian.manassiev@mongodb.com', 'name': 'Kaloian Manassiev', 'username': 'kaloianm'}

Message: SERVER-31204 Make `shardCollection` bypass the cache to read the `sharded` database property
Branch: v3.4
https://github.com/mongodb/mongo/commit/b0e6403de3c169d83df070605f6d05dbdb87cf4d

Comment by Githook User [ 22/Sep/17 ]

Author:

{'email': 'kaloian.manassiev@mongodb.com', 'name': 'Kaloian Manassiev', 'username': 'kaloianm'}

Message: SERVER-31204 Forward-port changes to enable_sharding_basic.js
Branch: master
https://github.com/mongodb/mongo/commit/8b64a10e341668dc6f8762c9c24977577e922398

Generated at Thu Feb 08 04:26:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.