This method is only available on newer versions.
The first available version (v8.1.1) is shown here.
keep_alive(threshold = @keepalive)
public
Prod any connections
that have been idle for longer than the configured keepalive time. This
will incidentally verify the connection
is still alive, but the main purpose is to show the server (and any
intermediate network hops) that we’re still here and using the connection.
# File activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb, line 825
def keep_alive(threshold = @keepalive)
return if threshold.nil?
sequential_maintenance -> c { (c.seconds_since_last_activity || 0) > c.pool_jitter(threshold) } do |conn|
# conn.active? will cause some amount of network activity, which is all
# we need to provide a keepalive signal.
#
# If it returns false, the connection is already broken; disconnect,
# so it can be found and repaired.
conn.disconnect! unless conn.active?
end
end