249 — StaleDbVersion
sharding
The database version is stale — routing metadata has changed
What is happening?
StaleDbVersion is returned when a shard receives a command with a database version that does not match its current knowledge. This occurs after movePrimary operations, database creation, or when the config server metadata changes. The driver or mongos normally retries transparently after refreshing the routing table.
Common causes
- movePrimary was recently executed and routing tables are refreshing
- Database was dropped and recreated while operations were in-flight
- Config server metadata was updated but the shard cache is stale
- Multiple mongos instances with different routing cache states