Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-574

Improve exception messaging when failing fast waiting for a connection

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.10.0
    • Affects Version/s: None
    • Component/s: API
    • None

      The maximum number of threads that the driver allows to have waiting in a queue for a connection from the pool is

      _options.connectionsPerHost * _options.threadsAllowedToBlockForConnectionMultiplier

      which defaults to 50 (10 * 5).

      Past that number the driver throws a SemaphoresOut exception with the message "Out of semaphores to get db connection".

      This is confusing to users, since the fact that the driver uses a semaphore to enforce this limit is not something users generally need to be aware of.

      The driver should throw a less confusing exception with a message more like "Exceeded the maximum number of threads that may be waiting for a connection to become available from the pool. The maximum is calculated as the product of connectionsPerHost (10) and threadsAllowedToBlockForConnectionMultiplier (5) in com.mongodb.MongoOptions"

            Assignee:
            bryan.reinero Bryan Reinero
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: