Old document is being read on one thread even though it has been updated on another

The is an instance on dev where a geometry is loaded and the display name is not being set correctly.

After adding logging, the following sequence can be seen:

[2022-05-04 16:19:35.449] INFO ( 75) Mns.Map.Data.Cache.MongoItem - **** Updated display name to 'New Name'.
[2022-05-04 16:19:35.449] INFO ( 75) Mns.Map.Data.Cache.MongoItem - **** Display name 'Identification\Display Name' in database is 'New Name'.
[2022-05-04 16:19:35.531] INFO (RawQ (Geometries)) Mns.Map.Data.Cache.MongoDataCache - Existing version of 'hw\rainfall\geometry types\ian\new name' is 0.
[2022-05-04 16:19:35.885] INFO (RawQ (Geometries)) Mns.Map.Calculator.ItemInfoCache - Adding 'hw\rainfall\geometry types\ian\new name' to the property descriptor cache due to data based property change(s).
[2022-05-04 16:19:35.885] INFO (RawQ (Geometries)) Mns.Map.Data.Cache.MongoItem - **** Getting 'new name' from the database for 'Identification\Display Name.
[2022-05-04 16:19:35.885] INFO (RawQ (Geometries)) Mns.Map.Calculator.ItemInfoCache - **** Checking if display name 'new name' is in the cache with fromParent = 'False'.
[2022-05-04 16:19:35.885] INFO (RawQ (Geometries)) Mns.Map.Calculator.ItemInfoCache - **** Adding 'Identification\Display Name' new name' to cache with fromParent = 'False' for '62729987590b4f4994a27e50' and 'hw\rainfall\geometry types\ian\new name'
[2022-05-04 16:19:35.908] INFO (RawQ (Geometries)) Mns.Map.Calculator.ItemInfoCache - The descriptor contains 'new name'.
[2022-05-04 16:19:36.060] INFO ( 75) Mns.Map.Calculator.ItemInfoCache - Removing 'hw\rainfall\geometry types\ian\new name' from property descriptor cache due to property change for 'Calculation\Minimum Start Time'.
[2022-05-04 16:19:36.060] INFO ( 75) Mns.Map.Data.Cache.MongoItem - **** Getting 'New Name' from the database for 'Identification\Display Name.

So the 2nd line shows that the display name is being set to “New Name”.

However the RawQ thread is still getting “new name” from the database EVEN though the “New Name” has been written to the database.

As can be seen in the logging for thread 75, the “New Name” property is being read on this thread correctly.

Has anyone got any ideas on what is going wrong?

You did not share your code so it is hard to tell what is wrong. But here are few things to consider.

Until you receive the UpdateResult the write is not necessarily committed to the DB.

Depending of your WriteConcern, ReadConcern and ReadPreference, the write is not necessarily commit to the replica set instance that you are reading from. Since sending the write and receive the UpdateResult involves I/0, then chances that a context switch occurs are high and it is possible that you read before the write is completed.

From your class names, it looks like you have some cache involve, it is not clear, in the absence of the code, what you do with the cache. may it is the cache that is giving you the wrong result.