[SERVER-33344] Commands that are not allowed on sharded collections should target the primary shard with shardVersion UNSHARDED Created: 14/Feb/18  Updated: 12/Dec/23

Status: Backlog
Project: Core Server
Component/s: Sharding
Affects Version/s: 3.6.2, 3.7.2
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Esha Maharishi (Inactive) Assignee: Backlog - Cluster Scalability
Resolution: Unresolved Votes: 0
Labels: PM-1017, RachitaD
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Cluster Scalability
Participants:

 Description   

Today, for commands that are not allowed on sharded collections, mongos checks its cache and if the cache says the collection is sharded, mongos returns an error to the client without ever contacting any shard.

This is wrong, because mongos's cache could be stale.

Instead, mongos should assume its cache is stale (i.e., assume the collection is unsharded no matter what its cache says) and target the primary shard with shardVersion UNSHARDED. If the collection is actually sharded, the shard will return StaleShardVersion. Mongos should catch StaleShardVersion for these commands and convert it to IllegalOperation (rather than letting it bubble up to the service entry point and making the command be retried repeatedly).

As part of fixing this, we should update the safe_secondary_reads*.js tests' expected behavior of "unshardedOnly" commands.


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