Recently MongoDB will often suddenly hang up, check log found the following error:
Copy Code code as follows:
Tcmalloc:large alloc 2061584302080 bytes = = (Nil) @
Tue Nov 17:45:04.539 out of memory, printing stack and exiting:
0xdddd81 0x6cfb4e 0x121021d 0xafcc1f 0xaf815f 0xaf8d1d 0xaf8e0f 0xaf52ae 0xaf53c9 0xb1eb11 0x8ab6a2 0x8d78ca 0x8d951d 0x8d Aa72 0xa80970 0xa8523c 0x9f9079 0x9fa5a3 0x6e8b88
./mongod (_ZN5MONGO15PRINTSTACKTRACEERSO+0X21) [0xdddd81]
./mongod (_ZN5MONGO14MY_NEW_HANDLEREV+0X3E) [0x6cfb4e]
./mongod (_ZNWM+0X6D) [0x121021d]
./mongod (_znst6vectorin5mongo18documentsourcesort9keyanddocesais2_ee7reserveem+0x6f) [0xafcc1f]
./mongod (_zn5mongo18documentsourcesort12populatetopkev+0x6f) [0xaf815f]
./mongod (_zn5mongo18documentsourcesort8populateev+0x2d) [0xaf8d1d]
./mongod (_ZN5MONGO18DOCUMENTSOURCESORT3EOFEV+0XF) [0xaf8e0f]
./mongod (_zn5mongo18documentsourceskip7skipperev+0x6e) [0xaf52ae]
./mongod (_zn5mongo18documentsourceskip3eofev+0x9) [0XAF53C9]
./mongod (_ZN5MONGO8PIPELINE3RUNERNS_14BSONOBJBUILDERERSS+0X1B1) [0XB1EB11]
./mongod (_zn5mongo15pipelinecommand3runerkssrns_7bsonobjeirssrns_14bsonobjbuildereb+0x132) [0X8AB6A2]
./mongod (_ZN5MONGO12_EXECCOMMANDEPNS_7COMMANDERKSSRNS_7BSONOBJEIRSSRNS_14BSONOBJBUILDEREB+0X3A) [0X8D78CA]
./mongod (_ZN5MONGO7COMMAND11EXECCOMMANDEPS0_RNS_6CLIENTEIPKCRNS_7BSONOBJERNS_14BSONOBJBUILDEREB+0X71D) [ 0X8D951D]
./mongod (_zn5mongo12_runcommandsepkcrns_7bsonobjerns_11_bufbuilderins_16trivialallocatoreeerns_ 14BSONOBJBUILDEREBI+0X5F2) [0x8daa72]
./mongod (_zn5mongo11runcommandsepkcrns_7bsonobjerns_5curoperns_11_bufbuilderins_16trivialallocatoreeerns_ 14BSONOBJBUILDEREBI+0X40) [0xa80970]
./mongod (_ZN5MONGO8RUNQUERYERNS_7MESSAGEERNS_12QUERYMESSAGEERNS_5CUROPES1_+0XD7C) [0xa8523c]
./mongod () [0x9f9079]
./mongod (_zn5mongo16assembleresponseerns_7messageerns_10dbresponseerkns_11hostandporte+0x383) [0X9FA5A3]
./mongod (_zn5mongo16mymessagehandler7processerns_7messageepns_21abstractmessagingportepns_9lasterrore+0x98) [ 0X6E8B88]
./mongod (_ZN5MONGO17PORTMESSAGESERVER17HANDLEINCOMINGMSGEPV+0X42E) [0xdca34e]
Memory overflow, at first I thought it was some sort of no index, then some places added after the index or will appear, think carefully, if it is not indexed, it will not let the whole mongodb downtime.
A list of such submitted Bugs SERVER-10136 (https://jira.mongodb.org/browse/SERVER-10136) was later found on the issue of MongoDB.
The original aggregation If you pass a $skip particularly large value, it will overflow memory. I see this bug has been fixed, but in the 2.5.2 version, the latest stable version is 2.4.8. So we need to control in our own application, so that the value of $skip should not exceed the total length.