Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-6580

MongoDB driver leaks idle connections

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: 6.10.0
    • Component/s: None
    • 3

      Use Case

      We're using mongodb's official clients with three different scenarios:

      • Parse Server
      • Mongoose
      • Vanilla MongoDB driver

      We're consistently observing increasing idle connections at the server side. The `currentOp` shows increasing connections that is `active: false`. After a long-time running, the services will finally run out of connections, and some DB queries will stuck forever

      After digging the source code, we successfully stablised idle connection number by combining `minPoolSize` and `maxIdleTimeoutMS`. The first option triggers a full sweep every 100ms, and the later one will help the sweep logic to clean up stale connection.

      So based on these observations, we're pretty sure that there's a leakage in the client code. It seems that the client can't utilize all idle connections in the pool, and gradually release more and more idle connections to the pool. Since it can't utilize the idle connections, when the pool is full of idle connections, it stucks for some db queries.

       

      Screenshots

      The server connections number before and after `minPoolSize&maxIdleTimeoutMS`, the connections will reach the pool limit gradually:

        1. script.js
          2 kB
        2. image-2024-11-25-10-33-25-689.png
          image-2024-11-25-10-33-25-689.png
          715 kB

            Assignee:
            aditi.khare@mongodb.com Aditi Khare
            Reporter:
            kassiansun@outlook.com Kassian Sun
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: