问题场景: 服务端用 nodejs+mongoose+node-schedule 跑了些定时任务,执行 bulkWrite 操作,代码大概如下:
updateOne: {
filter: {id: id},
update: {$set: item},
upsert: false
}
在某时刻跑太多任务时,mongodb 偶发性会挂掉,出现以下错误:
MongoBulkWriteError: connection 20 to 127.0.0.1:27017 closed
这时我只能临时执行一下systemctl restart mongod命令重启一下就好了,请问大佬们,这是不是写入的数据太多了超过限制呢?是什么原因呢?该如何优化?谢谢!
