File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -476,7 +476,12 @@ def next_session(server, force=false) #:nodoc:
476
476
return connection
477
477
end
478
478
479
- @open_connections += 1
479
+ # Only increment the open_connections count if the connection
480
+ # is not being forced. Incase of a force, it will already be
481
+ # incremented.
482
+ if !force
483
+ @open_connections += 1
484
+ end
480
485
end
481
486
482
487
begin
@@ -542,6 +547,10 @@ def realize_pending_connections! #:nodoc:
542
547
count = concurrent_connections ? ( concurrent_connections - open_connections ) : @pending_sessions . length
543
548
count . times do
544
549
session = @pending_sessions . pop or break
550
+ # Increment the open_connections count here to prevent
551
+ # creation of connection thread again before that is
552
+ # incremented by the thread.
553
+ @session_mutex . synchronize { @open_connections += 1 }
545
554
@connect_threads << Thread . new do
546
555
session . replace_with ( next_session ( session . server , true ) )
547
556
end
You can’t perform that action at this time.
0 commit comments