db.stats() 是对 MongoDB 的阻塞调用吗?

Is db.stats() a blocking call for MongoDB?

在研究如何检查 MongoDB 的大小时,我发现 this comment:

Be warned that dbstats blocks your database while it runs, so it's not suitable in production. https://jira.mongodb.org/browse/SERVER-5714

查看链接的错误报告(仍处于打开状态),它引用了 Mongo docs as saying:

Command takes some time to run, typically a few seconds unless the .ns file is very large (via use of --nssize). While running other operations may be blocked.

但是,当我查看当前的 Mongo 文档时,我没有找到该文本。相反,they say:

The time required to run the command depends on the total size of the database. Because the command must touch all data files, the command may take several seconds to run.

For MongoDB instances using the WiredTiger storage engine, after an unclean shutdown, statistics on size and count may off by up to 1000 documents as reported by collStats, dbStats, count. To restore the correct statistics for the collection, run validate on the collection.

这是否意味着 WiredTiger 存储引擎通过保持持续的统计信息将此更改为非阻塞调用?

游戏有点晚了,但我在寻找答案时发现了这个问题,答案是:是的,直到 3.6.12 / 4.0.5 它正在获取一个"shared" 锁 ("R") 会在执行期间阻止所有写请求。之后它现在是一个 "intent shared" 锁 ("r"),它不会阻止写请求。读取请求未受影响。

来源:https://jira.mongodb.org/browse/SERVER-36437