-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 5.0.0, 5.1.0, 5.2.0-rc1
-
Component/s: Sharding
-
Fully Compatible
-
ALL
-
v5.2, v5.1, v5.0
-
Sharding 2022-01-10, Sharding 2022-01-24
-
30
-
3
ShardServerOpObserver::onCreateCollection() sets the filter metadata for the collection as unsharded if the collection isn't already known to be sharded. This behavior isn't something which can be changed without significant work from Sharding EMEA, although it would probably be better to leave the filtering metadata as unknown.
The following scenario can therefore lead the recipient shard primary to wrongly believe the temporary resharding collection is unsharded and for it to throw a NamespaceNotSharded exception from assertCanExtractShardKeyFromDocs().
- Recipient shard primary in term=1 is told by coordinator to refresh on the temporary resharding collection. At this point the recipient shard primary knows the temporary resharding collection is sharded.
- Recipient shard primary in term=1 constructs a RecipientStateMachine and waits for all donor shards to be prepared to donate.
- Recipient shard primary in term=1 is told by coordinator all donor shards are prepared to donate.
- Recipient shard primary in term=1 is transitions from RecipientStateEnum::kAwaitingFetchTimestamp to RecipientStateEnum::kCreatingCollection.
- An election occurs and there's a new recipient shard primary in term=2.
- Recipient shard primary in term=2 clears the filtering metadata for the temporary resharding collection on step-up.
- Recipient shard primary in term=2 creates the temporary resharding collection. ShardServerOpObserver::onCreateCollection() causes the recipient shard primary to set the filtering metadata for the temporary resharding collection as unsharded.
This happens because the recipient shard primary in term=2 resumes without being guaranteed it has itself refreshed from the config server and set the filter metadata for the temporary resharding collection as sharded. One solution is to have the recipient shard primary clear the filtering metadata for the temporary resharding collection after creating it so that resharding's collection cloning and resharding's oplog application can simply refresh to set it as sharded.
- is related to
-
SERVER-59023 Resharding can fail with NamespaceNotSharded following a primary failover on a recipient shard
- Closed