Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2366

Prevent unnecessary goroutines when minPoolSize > maxPoolSize

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.9.2
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Not Needed

      Currently, the pool.maintain() goroutine will create up to one goroutine per requested connection to satisfy minPoolSize. In the case that minPoolSize > maxPoolSize, many of those created goroutines will be stuck waiting for connections indefinitely (no new connections are created once maxPoolSize is reached).

      This configuration is technically invalid, but it seems that the Go driver doesn't currently return a configuration error when minPoolSize > maxPoolSize. From the CMAP spec:

        /**
         *  The minimum number of Connections that MUST exist at any moment
         *  in a single connection pool.
         *  If specified, MUST be an integer >= 0. If maxPoolSize is > 0
         *  then minPoolSize must be <= maxPoolSize
         *  Defaults to 0.
         */
        minPoolSize?: number;
      

      Either update pool.maintain() to prevent creating goroutines that will be blocked indefinitely when trying to satisfy minPoolSize or update the configuration option validation to return an error when minPoolSize > maxPoolSize

            Assignee:
            qingyang.hu@mongodb.com Qingyang Hu
            Reporter:
            matt.dale@mongodb.com Matt Dale
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: