class Reaper

Ruby on Rails 8.1.2

Since v4.0.13

Available in: v4.0.13 v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Active Record Connection Pool Reaper

The reaper is a singleton that exists in the background of the process and is responsible for general maintenance of all the connection pools.

It will reclaim connections that are leased to now-dead threads, ensuring that a bad thread can’t leak a pool slot forever. By definition, this involves touching currently-leased connections, but that is safe because the owning thread is known to be dead.

Beyond that, it manages the health of available / unleased connections:

* retiring connections that have been idle[1] for too long
* creating occasional activity on inactive[1] connections
* keeping the pool prepopulated up to its minimum size
* proactively connecting to the target database from any pooled
  connections that had lazily deferred that step
* resetting or replacing connections that are known to be broken

[1]: “idle” and “inactive” here distinguish between connections that have not been requested by the application in a while (idle) and those that have not spoken to their remote server in a while (inactive). The former is a desirable opportunity to reduce our connection count (idle_timeout); the latter is a risk that the server or a firewall may drop a connection we still anticipate using (avoided by keepalive).

Inherits from

Object

Attributes

Methods (defined here)

Private methods

(1) Implementation detail — not part of the public API.

Methods (inherited)

From Object (17)
From ActiveSupport::NumericWithFormat (2)

Type at least 2 characters to search.

↑↓ navigate · open · esc close