我有一个内置在 node.js 中的 REST 服务,带有 Restify 和 Mongoose,还有一个 mongoDB,其中包含大约 30.000 个常规大小的文档。 我的 Node 服务通过 pmx 和 pm2 运行。
昨天,突然, Node 开始用消息“MongoError:拓扑被破坏”来解决错误,仅此而已。 我不知道这是什么意思,什么可能触发了这个。谷歌搜索时也找不到太多东西。所以我想我会在这里问。
今天重启 Node 服务后,错误停止了。 我也有其中一个在生产中运行,这让我害怕,这可能在任何给定时间发生在其中运行的设置的一个非常关键的部分......
我正在使用上述软件包的以下版本:
最佳答案
这似乎意味着您的 Node 服务器与您的 MongoDB 实例的连接在尝试写入时被中断。
看看Mongo source code that generates that error
Mongos.prototype.insert = function(ns, ops, options, callback) {
if(typeof options == 'function') callback = options, options = {};
if(this.s.state == DESTROYED) return callback(new MongoError(f('topology was destroyed')));
// Topology is not connected, save the call in the provided store to be
// Executed at some point when the handler deems it's reconnected
if(!this.isConnected() && this.s.disconnectHandler != null) {
callback = bindToCurrentDomain(callback);
return this.s.disconnectHandler.add('insert', ns, ops, options, callback);
}
executeWriteOperation(this.s, 'insert', ns, ops, options, callback);
}
这似乎与评论中引用的 Sails 问题无关,因为没有安装任何升级来引发崩溃或“修复”
https://stackoverflow.com/questions/30909492/