2
當前使用node.js(Native MongoDB)驅動程序與Mongodb一起工作時,我知道可以設置池連接計數,但不管是否遵守相同的行爲。Mongo DB初始連接池保持打開狀態?
有問題的代碼:
(function init(){
db.connect("mongodb://localhost/test",function(err, database){
});
})();
這是日誌從服務器:
Thu Dec 06 20:19:32 [initandlisten] connection accepted from 127.0.0.1:58663 #6
(1 connection now open)
Thu Dec 06 20:19:32 [initandlisten] connection accepted from 127.0.0.1:58664 #7
(2 connections now open)
Thu Dec 06 20:19:32 [initandlisten] connection accepted from 127.0.0.1:58665 #8
(3 connections now open)
Thu Dec 06 20:19:32 [initandlisten] connection accepted from 127.0.0.1:58666 #9
(4 connections now open)
Thu Dec 06 20:19:32 [initandlisten] connection accepted from 127.0.0.1:58667 #10
(5 connections now open)
Thu Dec 06 20:19:36 [conn9] end connection 127.0.0.1:58666 (4 connections now op
en)
Thu Dec 06 20:19:36 [conn10] end connection 127.0.0.1:58667 (4 connections now o
pen)
Thu Dec 06 20:19:36 [conn8] end connection 127.0.0.1:58665 (4 connections now op
en)
Thu Dec 06 20:19:36 [conn6] end connection 127.0.0.1:58663 (4 connections now op
en)
Thu Dec 06 20:19:36 [conn7] end connection 127.0.0.1:58664 (4 connections now op
en)
的連接顯然尚未關閉當前打開的連接數不減少,即使連接正確遞增。意圖行爲?
PS。請不要使用用於mongodb的nodejs包裝來回答。
我無法用該代碼重現此行爲。無論我是否終止進程,或是在回調函數中放入'database.close();'調用,連接計數都會回落到0。 – JohnnyHK