Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 2 files changed
  • 4 commit comments
  • 1 contributor
Commits on Mar 20, 2013
@tenderlove tenderlove Revert "default the reaping frequency to 10 seconds"
mysql can't handle a parallel thread pinging the connection, so we can
get wrong results or segvs

This reverts commit 7cc588b.
7150a9d
@tenderlove tenderlove use `connect_poll` on pg so that reaping does not hurt the connection 34c7e73
View
6 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -238,7 +238,7 @@ def initialize(spec)
@checkout_timeout = spec.config[:checkout_timeout] || 5
@dead_connection_timeout = spec.config[:dead_connection_timeout] || 5
- @reaper = Reaper.new(self, spec.config[:reaping_frequency] || 10)
+ @reaper = Reaper.new self, spec.config[:reaping_frequency]
@reaper.run
# default max pool size to 5
@@ -406,7 +406,9 @@ def reap
synchronize do
stale = Time.now - @dead_connection_timeout
connections.dup.each do |conn|
- remove conn if conn.in_use? && stale > conn.last_use && !conn.active?
+ if conn.in_use? && stale > conn.last_use && !conn.active?
+ remove conn
+ end
end
end
end
View
3 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -519,8 +519,7 @@ def clear_cache!
# Is this connection alive and ready for queries?
def active?
- @connection.query 'SELECT 1'
- true
+ @connection.connect_poll != PG::PGRES_POLLING_FAILED
rescue PGError
false
end

Showing you all comments on commits in this comparison.

@MacksMind

Result on Mac:

1) Failure:
ActiveRecord::PostgresqlConnectionTest#test_reconnection_after_simulated_disconnection_with_verify [test/cases/adapters/postgresql/connection_test.rb:117]:
Should have a new underlying connection pid.
Expected [["26302"]] to not be equal to [["26302"]].

@MacksMind

Ok, I'm an idiot for not checking. This isn't Mac specific, because Travis isn't happy.

@jonleighton
Ruby on Rails member

I have deleted the failing test in 79c02e8.

@mjacobus

Same problem here. Rails 4.0.3 + mysql

I "solved" with two different approaches:
1. by increasing pool from 5 yo 7
2. by applying this monkey patch

Something went wrong with that request. Please try again.