diff --git a/HISTORY b/HISTORY index dc8dfb9..7a19684 100644 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,15 @@ +0.18.2 2009-12-21 +* Enabled support for keyf on group +* Signification GridStore performance improvement (thx., Sunny Hirai) +* Support :query option for Collection#distinct +* Support :finalize option for Collection#group +* (0.18.1) ObjectID#generation_time returns a created_at timestamp. +* Deprecated Command#group running as a JS eval; should now be run as a command. +* Deprecated Cursor#next_object for Cursor#next_document +* Character encoding fixes for C extension +* Enforce 4MB limit on document creation +* Simplified connection pooling code + 0.18.1 2009-12-05 * Fixed issue with negative dates in Ruby 1.9 * Minor refactorings for C extension and BSON classes diff --git a/lib/mongo/connection.rb b/lib/mongo/connection.rb index fdf7041..3b5300e 100644 --- a/lib/mongo/connection.rb +++ b/lib/mongo/connection.rb @@ -70,7 +70,6 @@ module Mongo # this is the number of seconds to wait for a new connection # to be released before throwing an exception. # - # # === Examples: # # # localhost, 27017 @@ -106,7 +105,10 @@ module Mongo # Pool size and timeout. @size = options[:pool_size] || 1 - @timeout = options[:timeout] || 1.0 + @timeout = options[:timeout] || 5.0 + + # Number of seconds to wait for threads to signal availability. + @thread_timeout = @timeout >= 5.0 ? (@timeout / 4.0) : 1.0 # Mutex for synchronizing pool access @connection_mutex = Monitor.new @@ -294,11 +296,6 @@ module Mongo private - # Get a socket from the pool, mapped to the current thread. - def checkout - obtain_socket - end - # Return a socket to the pool. def checkin(socket) @connection_mutex.synchronize do @@ -337,14 +334,14 @@ module Mongo # Check out an existing socket or create a new socket if the maximum # pool size has not been exceeded. Otherwise, wait for the next # available socket. - def obtain_socket + def checkout connect_to_master if !connected? start_time = Time.now loop do - if (Time.now - start_time) > 30 + if (Time.now - start_time) > @timeout raise ConnectionTimeoutError, "could not obtain connection within " + "#{@timeout} seconds. The max pool size is currently #{@size}; " + - "consider increasing it." + "consider increasing the pool size or timeout." end @connection_mutex.synchronize do @@ -364,13 +361,13 @@ module Mongo # Ruby 1.9's Condition Variables don't support timeouts yet; # until they do, we'll make do with this hack. def wait - Timeout.timeout(@timeout) do + Timeout.timeout(@thread_timeout) do @queue.wait end end else def wait - @queue.wait(@timeout) + @queue.wait(@thread_timeout) end end diff --git a/test/threading/test_threading_large_pool.rb b/test/threading/test_threading_large_pool.rb index 037ebdc..a600ce8 100644 --- a/test/threading/test_threading_large_pool.rb +++ b/test/threading/test_threading_large_pool.rb @@ -6,7 +6,7 @@ class TestThreadingLargePool < Test::Unit::TestCase include Mongo - @@db = Connection.new('localhost', 27017, :pool_size => 50, :timeout => 1).db('ruby-mongo-test') + @@db = Connection.new('localhost', 27017, :pool_size => 50, :timeout => 10).db('ruby-mongo-test') @@coll = @@db.collection('thread-test-collection') def set_up_safe_data