Search code examples
node.jsmongodbinfinite-loop

nodejs driver for mongodb enter infinite loop to ensure Min Pool Size


I use the official mongodb nodejs sdk with code

const MongoClient = require('mongodb').MongoClient

at the beginning, db read works well, however, after a while, code enter an infinite loop to function ensureMinPoolSize (see picture 1), is there anything wrong?

more info:

(1) my code is multi-thread (8 threads), every thread can read db,

(2) db pool setting as picture 2,


enter image description here


enter image description here


Solution

  • solved, thanks @dododo, this logic ensureMinPoolSize is running in the background thread and by design!

    the root cause is main thread enters an infinite loop, no available time to tackle data through the message channel from child thread.