Meteor app使用mongodb批量操作抛出超时异常

时间:2017-03-05 16:44:37

标签: mongodb meteor bulkupdate

我正在尝试插入一堆对象(大约14000个),但我总是得到超时错误。

我首先设置我的计时器:

  Mongo.setConnectionOptions({
    mongos: {
      socketOptions: {
        keepAlive: 1800000,
        connectTimeoutMS: 1800000,
        socketTimeoutMS: 1800000,
      },
    },
  });

然后我创建批量操作:

console.log(Mongo._connectionOptions.mongos.socketOptions);

  const bulk = IntegrityTest.rawCollection().initializeUnorderedBulkOp();
  const session = IntegrityTest.insert({
    // fields...
  });

  checkResult.flagged.forEach(function (item) {
    bulk.find({ _id: session }).update({
      $addToSet: {
        // fields...
      }
    });
  });

  bulk.find({ _id: session }).update({ $set: { finishedAt: new Date() } });
  bulk.execute({ w: "majority", wtimeout: 1800000 });

以上日志打印最初设置的内容:

  

{keepAlive:1800000,
    connectTimeoutMS:1800000,
    socketTimeoutMS:1800000}

5分钟后仍然会抛出超时错误:

  

C:\用户\ gatsu \应用程序数据\ Local.meteor \包\流星工具\ 1.4.2_6 \ MT-os.windows.x86_32 \ dev_bundle \服务器-LIB \ node_modules \纤维\ future.js:313   扔(前);

     

MongoError:连接0到127.0.0.1:3003超时

     

在Object.Future.wait   (C:\用户\ gatsu \应用程序数据\ Local.meteor \包\流星工具\ 1.4.2_6 \ MT-os.windows.x86_32 \ dev_bundle \服务器-LIB \ node_modules \纤维\ future.js:449:15)   在[对象   对象] ._。extend._nextObject(packages / mongo / mongo_driver.js:1024:47)   在[object Object] ._。extend.forEach(packages / mongo / mongo_driver.js:1058:22)   at [object Object] ._。extend.map(packages / mongo / mongo_driver.js:1068:10)   在[object Object] ._。extend.fetch(packages / mongo / mongo_driver.js:1092:17)   at [object Object] .Cursor。(匿名函数)[as fetch](packages / mongo / mongo_driver.js:907:44)   在[object Object] .MongoConnection.findOne(packages / mongo / mongo_driver.js:814:56)   在对象。 (包\ matb33_collection-hooks.js:658:16)   at Object.collection。(匿名函数)[as findOne](packages \ matb33_collection-hooks.js:137:21)   在[object Object] ._。extend.findOne(packages / mongo / collection.js:332:29)

     

在Function.MongoError.create(C:\ Users \ gatsu \ AppData \ Local.meteor \ packages \ npm-mongo \ 2.2.16_1 \ npm \ node_modules \ mongodb-core \ lib \ error.js:29:11 )   在Socket。 (C:\用户\ gatsu \应用程序数据\ Local.meteor \包\ NPM-蒙戈\ 2.2.16_1 \ NPM \ node_modules \ mongodb的核\ lib中\连接\ connection.js:184:20)   在Socket.g(events.js:260:16)   在emitNone(events.js:67:13)   at Socket.mit(event.js:166:7)at Socket._onTimeout(net.js:333:8)   在_runOnTimeout(timers.js:537:11)   在_makeTimerTimeout(timers.js:528:3)   在Timer.unrefTimeout(timers.js:597:5)

0 个答案:

没有答案