forked from ileitch/rapns
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch PostgreSQLAdapter in Rails 3.1.0 and 3.1.1 to fix a reconnectio…
…n issue.
- Loading branch information
Showing
6 changed files
with
54 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
if defined?(Rails) && ActiveRecord::Base.configurations[Rails.env]['adapter'] == 'postgresql' | |||
if Rails::VERSION::STRING == '3.1.0' || Rails::VERSION::STRING == '3.1.1' | |||
STDERR.puts '[WARNING] Patched PostgreSQLAdapter to fix reconnection bug: https://github.com/rails/rails/issues/3160.' | |||
require "rapns/daemon/patches/rails/#{Rails::VERSION::STRING}/postgresql_adapter.rb" | |||
end | |||
end |
12 changes: 12 additions & 0 deletions
12
lib/rapns/daemon/patches/rails/3.1.0/postgresql_adapter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,12 @@ | |||
module ActiveRecord | |||
module ConnectionAdapters | |||
class PostgreSQLAdapter < AbstractAdapter | |||
def clear_cache! | |||
@statements.each_value do |value| | |||
@connection.query "DEALLOCATE #{value}" if active? | |||
end | |||
@statements.clear | |||
end | |||
end | |||
end | |||
end |
17 changes: 17 additions & 0 deletions
17
lib/rapns/daemon/patches/rails/3.1.1/postgresql_adapter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,17 @@ | |||
module ActiveRecord | |||
module ConnectionAdapters | |||
class PostgreSQLAdapter < AbstractAdapter | |||
class StatementPool < ConnectionAdapters::StatementPool | |||
def dealloc(key) | |||
@connection.query "DEALLOCATE #{key}" if connection_active? | |||
end | |||
|
|||
def connection_active? | |||
@connection.status == PGconn::CONNECTION_OK | |||
rescue PGError | |||
false | |||
end | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters