flushRouterConfig

On this page本页内容

Definition定义

flushRouterConfig

flushRouterConfig marks the cached routing table for a sharded cluster as stale, causing the next operation that requests the routing table to refresh the cache. Management of the routing table cache is generally handled automatically by the cluster. You should only need to run the flushRouterConfig command manually in specific instances, as indicated under Considerations.

Note

Starting in MongoDB 4.4, running flushRouterConfig is no longer required after executing the movePrimary or dropDatabase commands. These two commands now automatically refresh a sharded cluster’s routing table as needed when run.

Syntax语法

Starting in MongoDB 4.0.6 (and 3.6.11), the flushRouterConfig is available on both mongos and mongod instances, and has the following syntax:语法如下所示:

Note

In MongoDB 4.0.5 and earlier (and 3.6.10 and earlier), flushRouterConfig is only available for mongos instances and can only flush the cache for all databases and their collections:

db.adminCommand("flushRouterConfig")
db.adminCommand( { flushRouterConfig: 1 } )

Considerations考虑事项

Generally, a sharded cluster’s routing table is automatically refreshed as needed as part of normal operation. However, you should manually issue the flushRouterConfig command in the following instances: