Details
Description
If $out runs over a sharded collection after a movePrimary operation, $out will fail constantly with a StaleDbVersion until another operation refreshes the DbVersion on the new primary shard.
Events sequence leading to the bug:
- shard0 is the primary shard for mydb database.
- The sharded collection mydb.collA has chunks on shard0 and shard1
- A movePrimary for mydb is executed and the new primary is shard1.
- A $out operation over mydb.collA is launched and is redirected to shard1 as the primary of mydb.
- $out executes listCollection command here targeting shard0 because shard1 thinks it's the primary shard for mydb.
- The listCollection command fails with StaleDbVersion as expected and shard1 forwards the error to the router, so it never refreshes the DbVersion.