我有一个express.js应用程序,我使用mongodb作为数据库和Mongoose驱动程序。
还使用elasticsearch进行搜索。
经过几个小时mongodb崩溃后运行我的应用程序,我必须重新启动MongoD。
问题是没有显示任何错误,我不知道如何找到问题。
我只知道与mongodb查询有关的事情
这是我得到的错误:
Error
at Error.MongoError (/home/node/app/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/error.js:13:17)
at Function.MongoError.create (/home/node/app/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/error.js:29:11)
at Socket.<anonymous> (/home/node/app/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:140:22)
at Socket.g (events.js:180:16)
at Socket.emit (events.js:95:17)
at TCP.close (net.js:466:12)
这是我的一条路线:
router.get('/artist/:id/:path', function(req, res, next) {
var pageNumber = req.params.page;
var skip = pageNumber * 50;
var path = req.params.path;
var singerID = parseInt(req.params.id);
singer.findOne({"singerId":singerID}).exec(function(err, items) {
if(err) throw err;
var ArtistName = items.artist_name
Keyword.find( { $text: { $search: items.artist_name } } ).count().exec(function(err, count) {
Keyword.find( { $text: { $search: items.artist_name } } ).skip(skip).limit(50).lean().exec(function(err, items) {
var total = Math.ceil(count/50);
// random keyword
Keyword.count({}, function (err, count) {
if (err) {
return next(err);
}
var skip = Math.floor((Math.random() * count) + 1);
Keyword.find().skip(skip).limit(100).lean().exec(function(err, keywords) {
if (err) {
return next(err);
}
// res.send
res.render('singerPage',{singer: items, pageNumber:0,count:total,id:singerID,path:path,artistName:ArtistName,keywords:keywords});
});
}) // end random keyword
});
})
})
})
这是最后一个mongodb日志:
2015-08-13T06:53:08.285+0000 I QUERY [conn17] query music.keywords planSummary: COLLSCAN cursorid:35095187651 ntoreturn:100 ntoskip:444502 nscanned:0 nscannedObjects:444602 keyUpdates:0 writeConflicts:0 numYields:3474 nreturned:100 reslen:19070 locks:{ Global: { acquireCount: { r: 6950 } }, MMAPV1Journal: { acquireCount: { r: 3475 } }, Database: { acquireCount: { r: 3475 } }, Collection: { acquireCount: { R: 3475 } } } 113ms
2015-08-13T06:53:12.430+0000 I QUERY [conn18] query music.keywords planSummary: COLLSCAN cursorid:35263643264 ntoreturn:100 ntoskip:395246 nscanned:0 nscannedObjects:395346 keyUpdates:0 writeConflicts:0 numYields:3088 nreturned:100 reslen:14874 locks:{ Global: { acquireCount: { r: 6178 } }, MMAPV1Journal: { acquireCount: { r: 3089 } }, Database: { acquireCount: { r: 3089 } }, Collection: { acquireCount: { R: 3089 } } } 103ms
2015-08-13T06:53:23.580+0000 I QUERY [conn18] killcursors keyUpdates:0 writeConflicts:0 numYields:0 locks:{ Global: { acquireCount: { r: 2 } }, MMAPV1Journal: { acquireCount: { r: 1 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { R: 1 } } } 13ms
2015-08-13T06:53:27.776+0000 I QUERY [conn16] query music.keywords planSummary: COLLSCAN cursorid:35959352048 ntoreturn:100 ntoskip:407328 nscanned:0 nscannedObjects:407428 keyUpdates:0 writeConflicts:0 numYields:3183 nreturned:100 reslen:17946 locks:{ Global: { acquireCount: { r: 6368 } }, MMAPV1Journal: { acquireCount: { r: 3184 } }, Database: { acquireCount: { r: 3184 } }, Collection: { acquireCount: { R: 3184 } } } 107ms