[SERVER-57060] Rename of a sharded collection must bump the collection version Created: 19/May/21  Updated: 29/Oct/23  Resolved: 17/Jun/21

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 5.0.0-rc3, 5.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Sergi Mateo Bellido Assignee: Pierlauro Sciarelli
Resolution: Fixed Votes: 0
Labels: PM-1965-Milestone-1
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
depends on SERVER-57313 Pass the collection epoch and timesta... Closed
depends on SERVER-57316 Changing a few functions that rely on... Closed
depends on SERVER-57522 setFCV command should remove/add epoc... Closed
depends on SERVER-57523 Do not persist epochs and timestamps ... Closed
depends on SERVER-57524 Revisit DDL operations that are curre... Closed
depends on SERVER-57703 Move sharding_ddl_util.cpp into shard... Closed
is depended on by SERVER-57059 Rename op doesn't bump the collection... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v5.0
Sprint: Sharding EMEA 2021-05-31, Sharding EMEA 2021-06-28
Participants:

 Description   

Not bumping the collection version is a problem for scenarios like:

  1. Creation of Collection A
  2. Creation of Collection B
  3. Rename of A to B, dropping target collection.

Assuming that a router saw A and B before the rename, if this router tries to refresh its routing information about B after the rename, this refresh will hang forever.

The underlying problem is that since we didn't bump the collection version, the router thinks that the routing info it has about B is more recent than the one it gets from the config server.

Solution:

We have to bump the collection version. The Collection Version of B after the rename should be newer than the one we had for B before the rename.

  1. If we take the conservative approach, this would imply modifying all entries in config.chunks for this collection + its entry on config.collections. Doing that should be enough and it will behave similarly to what we do in refineShardKey. As a drawback we will have to update all chunks associated to the Collection which is something we tried to avoid as much as possible: that's why we replaced the namespaces by uuids, to avoid having to update all chunks.
  2. The other approach tries to avoid having to update all docs associated to the collection on config.chunks. Since the replacement of NSS by UUID on config.chunks, we believe that there is no reason to have the epoch and the timestamp on config.chunks. Thus, if we manage to get rid of those, the rename will only have to update config.collections. In order to support backward/forward compatibility we will have to do some minor modifications to the setFCV cmd.

We are going to implement the second option. The goal of this ticket is to add a new configserver command that should be called when we commit the rename operation. This new command should do the work being done + bumping the version (i.e. changing the timestamp and the epoch of the collection). We should also take the _kChunkOpLock lock, so we disallow weirds interleavings of rename collections with merge/split chunks.



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 21/Jun/21 ]

Author:

{'name': 'Pierlauro Sciarelli', 'email': 'pierlauro.sciarelli@mongodb.com', 'username': 'pierlauro'}

Message: SERVER-57060 Rename of a sharded collection must bump the collection version
Branch: v5.0
https://github.com/mongodb/mongo/commit/8cc222b80cadfec0b634a8db86e1ae1da068467b

Comment by Githook User [ 17/Jun/21 ]

Author:

{'name': 'Pierlauro Sciarelli', 'email': 'pierlauro.sciarelli@mongodb.com', 'username': 'pierlauro'}

Message: SERVER-57060 Rename of a sharded collection must bump the collection version
Branch: master
https://github.com/mongodb/mongo/commit/f90412db3e82dd2e6d43e63a74debc99b63b96da

Generated at Thu Feb 08 05:40:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.