diff options
author | Matthew Draper <matthew@trebex.net> | 2017-11-17 21:55:39 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2017-11-18 13:47:51 +1030 |
commit | f32cff5563f2188e657aa2fd9f8513f0da4a49ca (patch) | |
tree | a3ebdf2ba035c8c23e7a67d2e62b78669b471a4d /activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | |
parent | c39ed435eb578c79867552c66da7eeb035fa58ad (diff) | |
download | rails-f32cff5563f2188e657aa2fd9f8513f0da4a49ca.tar.gz rails-f32cff5563f2188e657aa2fd9f8513f0da4a49ca.tar.bz2 rails-f32cff5563f2188e657aa2fd9f8513f0da4a49ca.zip |
Improve AR connection fork safety
Use whatever adapter-provided means we have available to ensure forked
children don't send quit/shutdown/goodbye messages to the server on
connections that belonged to their parent.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 345983a655..df11391fa7 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -366,6 +366,19 @@ module ActiveRecord reset_transaction end + # Immediately forget this connection ever existed. Unlike disconnect!, + # this will not communicate with the server. + # + # After calling this method, the behavior of all other methods becomes + # undefined. This is called internally just before a forked process gets + # rid of a connection that belonged to its parent. + def discard! + # This should be overridden by concrete adapters. + # + # Prevent @connection's finalizer from touching the socket, or + # otherwise communicating with its server, when it is collected. + end + # Reset the state of this connection, directing the DBMS to clear # transactions and other connection-related server-side state. Usually a # database-dependent operation. |