Contradictory information about Sharding

In Chapter 3: Sharding / Shard Keys -> Quiz -> See detailed answer;
one can read this:

Sharding is a permanent operation, and the chosen shard key is immutable. However, the shard key values are mutable.

In the video, at time position 6:00, one can read this:

Shard Key Values are immutable.

Which one is true 1) or 2) :
1) “the shard key values are mutable” ?
2) “Shard Key Values are immutable” ?

Hello @Michel_Bouchet,

There is a note on this video:

At 2:35, Ravind mentions that the shard key value is immutable.

As of MongoDB 4.2, the shard key value is mutable, even though the shard key itself is immutable. If you’re interested, you can read more in the Shard Key documentation.

And from the docs for shard keys.

Starting in MongoDB 4.2, you can update a document’s shard key value unless the shard key field is the immutable _id field. Before MongoDB 4.2, a document’s shard key field value is immutable.

  • Be aware what’s the MongoDB version for the test, I believe it’s 4.0
1 Like

OK. Thanks!

Hi @Michel_Bouchet,

Sorry for the confusion. There has been some changes in the newer release of MongoDB since the time of the recording of the video. We will update the lecture notes.

Please note that some additional change happened in MongoDB version 4.4 as well.

~ Shubham