[SERVER-36959] _shardServerShardCollection should use afterOpTime when counting chunks on the config server Created: 31/Aug/18  Updated: 29/Oct/23  Resolved: 26/Sep/18

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 4.0.2
Fix Version/s: 4.0.4, 4.1.4

Type: Bug Priority: Major - P3
Reporter: Matthew Saltz (Inactive) Assignee: Janna Golden
Resolution: Fixed Votes: 0
Labels: sharding-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.0
Sprint: Sharding 2018-10-08
Participants:
Linked BF Score: 16

 Description   

When we shard a collection, _shardServerShardCollection runs a count command on the config.chunks collection to make sure there are no chunks already in the collection. But, right now, the count query uses readConcern local, which can cause a problem in the following scenario

  1. Create a sharded collection
  2. Drop the sharded collection, which succeeds on the config server primary
  3. Try to create a sharded collection with the same name
  4. _shardServerShardCollection runs a count command to see if chunks exist from a previous sharded collection with the same name
  5. The count command targets the config server secondary, where the replication of the drop from the previous collection has not completed, and so there are still chunks in the collection
  6. The _shardServerShardCollection command fails with the error "ManualInterventionRequired: A previous attempt to shard collection <collection name> failed after writing some initial chunks to config.chunks. Please manually delete the partially written chunks for collection test.user from config.chunks", even though the previous drop completed successfully

We should use readAfterOpTime to do this count command so that even if we read from a config server secondary, we'll wait until previous operations have replicated.



 Comments   
Comment by Githook User [ 24/Oct/18 ]

Author:

{'name': 'jannaerin', 'email': 'golden.janna@gmail.com', 'username': 'jannaerin'}

Message: SERVER-36959 Use afterOpTime when counting chunks in _shardsvrShardCollection

(cherry picked from commit 9732cc2ec75ead567015db7e892091ac3ce2e35d)
Branch: v4.0
https://github.com/mongodb/mongo/commit/67a110a2bfb42aaca26933c4f5fffbf5edb418cf

Comment by Githook User [ 26/Sep/18 ]

Author:

{'name': 'jannaerin', 'email': 'golden.janna@gmail.com', 'username': 'jannaerin'}

Message: SERVER-36959 Use afterOpTime when counting chunks in _shardsvrShardCollection
Branch: master
https://github.com/mongodb/mongo/commit/9732cc2ec75ead567015db7e892091ac3ce2e35d

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