我的数据库有问题。
我经常(一天几次)在查询期间崩溃。它抛出这个错误:
PoolClearedError [MongoPoolClearedError]: Connection pool for db2.prod.someDomain.com:27017 was cleared because another operation failed with: "connection <monitor> to [ip:v6:add:ress::]:27017 timed out"
at ConnectionPool.processWaitQueue (/var/www/api/prod/node_modules/mongoose/node_modules/mongodb/lib/cmap/connection_pool.js:520:82)
at ConnectionPool.clear (/var/www/api/prod/node_modules/mongoose/node_modules/mongodb/lib/cmap/connection_pool.js:251:14)
at updateServers (/var/www/api/prod/node_modules/mongoose/node_modules/mongodb/lib/sdam/topology.js:461:29)
at Topology.serverUpdateHandler (/var/www/api/prod/node_modules/mongoose/node_modules/mongodb/lib/sdam/topology.js:332:9)
at Server.<anonymous> (/var/www/api/prod/node_modules/mongoose/node_modules/mongodb/lib/sdam/topology.js:444:77)
at Server.emit (node:events:513:28)
at Server.emit (node:domain:489:12)
at markServerUnknown (/var/www/api/prod/node_modules/mongoose/node_modules/mongodb/lib/sdam/server.js:298:12)
at Monitor.<anonymous> (/var/www/api/prod/node_modules/mongoose/node_modules/mongodb/lib/sdam/server.js:58:46)
at Monitor.emit (node:events:513:28) {
address: 'db.prod.someDomain.com:27017',
[Symbol(errorLabels)]: Set(1) { 'RetryableWriteError' }
}
我已经尝试了一些更改,从降低数据库的写入速率和读取速率开始,但不明白为什么它崩溃......我无法重现该错误,因为它是随机发生的,并且当我读取我的服务器时监控信息显示,CPU、RAM、SSD I/O均处于低水平。
这是我的配置:
mongoose last version
mongodb js driver last version
mongodb last version
1 replicaset with 2 nodes
Each node has 32GO ram + 12 core Xeon processor
Full database size is around 130GO, biggest collection has 70M documents, total index size is around 24GO
我已经找到了导致此错误的原因,如果有人遇到我的情况,请在此处分享。
事实上,问题既不是来自我的数据库,也不是来自我的网络……而是来自我的客户端服务器。
有时我的客户端服务器的 CPU 过载,所有核心都达到 100%。在这些情况下,我猜它无法及时处理 mongoDB 请求,从而导致此 MongoPoolClearedError。
出现此错误的任何人都应该在客户端检查服务器是否过载。