Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-936

min_pool_size puts the same connection into the pool multiple times

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 2.0.5
    • Affects Version/s: 2.0.4
    • Component/s: Connections
    • None

      https://github.com/mongodb/mongo-ruby-driver/blob/master/lib/mongo/server/connection_pool/queue.rb#L99

      http://ruby-doc.org/core-2.2.0/Array.html#method-c-new

      Array#new/2 will populate the array with the given default value multiple times. This makes everything go to hell if you specify min_pool_size in a multi-threaded app, since the same connection instance can be checked out multiple times and then you get lovely things like cross-talk between messages.

      The fix is here: https://github.com/cheald/mongo-ruby-driver/commit/2ae036667c04db60519ab4fa397b1add30628464

      Though, I am curious, why is Ruby's Queue construct (which is threadsafe and already heavily battle-tested) not being used here?

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            cheald Chris Heald
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: