moleculerjs / moleculer-db

:battery: Database access service mixins for Moleculer
https://moleculer.services/
MIT License
152 stars 122 forks source link

"server instance pool was destroyed" in a persistence service with mongo when mongo db restarts #333

Open developez opened 1 year ago

developez commented 1 year ago

I got a persistence service that uses mongo. When mongo restarts, the persistence service returns "server instance pool was destroyed". I think in reset the persistence service when that thing happens. Is there another idea to deal with this???

Moleculer 0.14.12

intech commented 1 year ago

Are you using moleculer-db-adapter-mongo?

zoernert commented 10 months ago

I could confirm that this happens on a Mongo service restart (maybe due to memory) - the pool is not reestablished if the mongo service is down for more than 40 seconds during restart. It should be possible to fix using connection parameters and setting the retry timeout to a higher value:

new MongoDBAdapter("Connection URI",{
            poolSize: 100,
            wtimeout: 2500,
            connectTimeoutMS: 10000,
        }