How Enabling FCV on Sharded Clusters works

Hello,

I’m trying to understand how setting FCV on a sharded cluster works. Taking as an example version 4.0.
According to the documentation setting new FCV on a shared cluster is being done through a mongos instance.
I tried to check the code and found the following workflow:

  1. FCV is triggered on mongos : https://github.com/mongodb/mongo/blob/91e3352a1aa717674575fce3cc6edb2f279a4479/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp
  2. mongos sends the command to config servers: https://github.com/mongodb/mongo/blob/91e3352a1aa717674575fce3cc6edb2f279a4479/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp#L94
  3. config replicaset executes https://github.com/mongodb/mongo/blob/v4.0/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
  4. it does that through the block dedicated to config server: https://github.com/mongodb/mongo/blob/v4.0/src/mongo/db/commands/set_feature_compatibility_version_command.cpp#L184
  5. Within this block config will update to new FCV and trigger upgradeChunksHistory for each collection.
  6. It will trigger the upgrade of FCV on each shard: https://github.com/mongodb/mongo/blob/v4.0/src/mongo/db/commands/set_feature_compatibility_version_command.cpp#L226.
  7. setting FCV on config replicaset.
    ===============================
    As I understand from the above FCV is set on config replicaset after it was set on all shards.
    Locks, at least in version 4.0 seem to be set only at individual replicaset level, correct?
    Is this correct flow in case of a sharded cluster?

Thank you,
Cristian

Hi Cristian, why is important to know this. This is the kind of internal detail that is likely to change in future versions of MongoDB and shouldn’t make a difference to end users?