When we received a StaleDbVersion error during a batchWrite, in the ChunkManagerTargeter we locally decide if we need to refresh based on some version comparision and if this is the case we force a full refresh of the cached entry.
If multiple cuncurrent batchWrite operations hit the same StaleShardVersion they will all force a full refresh of the catalog without any kind of synchronization, causing several refreshes of the cached database metadata when actually only one is required.
When receiving a StaleShardVersion the ChunkManagerTargeter should only call CatalogCache::invalidateShardOrEntireCollectionEntryForShardedCollection() and expect that on the next CatalogCache lookup it will receive the refreshed metadata. In this new approach if we receive several StaleShardVersion concurrently with the same db version we will only perform one refresh.
- is related to
-
SERVER-58266 Stop forcing database version refreshes in chunk manager targeter
- Closed
- related to
-
SERVER-75333 The ChunkManagerTargeter unnecessarily invalidates just-refreshed routing info upon receiving UNSHARDED version
- Closed