Module: ActiveRecordHostPool

Defined in:
lib/active_record_host_pool/pool_proxy.rb,
lib/active_record_host_pool.rb,
lib/active_record_host_pool/version.rb,
lib/active_record_host_pool/connection_proxy.rb,
lib/active_record_host_pool/clear_query_cache_patch.rb,
lib/active_record_host_pool/connection_adapter_mixin.rb

Overview

ActiveRecord 6.0 introduced multiple database support. With that, an update has been made in github.com/rails/rails/pull/35089 to ensure that all query caches are cleared across connection handlers and pools. If you write on one connection, the other connection will have the update that occurred.

This broke ARHP which implements its own pool, allowing you to access multiple databases with the same connection (e.g. 1 connection for 100 shards on the same server).

This patch maintains the reference to the database during the cache clearing to ensure that the database doesn’t get swapped out mid-way into an operation.

This is a private Rails API and may change in future releases as they’re actively working on sharding in Rails 6 and above.

Defined Under Namespace

Modules: ClearOnHandlerPatch, ClearQueryCachePatch, DatabaseSwitch, PoolConfigPatch Classes: ConnectionProxy, PoolProxy

Constant Summary collapse

VERSION =
"2.1.0"

Class Attribute Summary collapse

Class Attribute Details

.loaded_db_adapterObject

Returns the value of attribute loaded_db_adapter.



9
10
11
# File 'lib/active_record_host_pool.rb', line 9

def loaded_db_adapter
  @loaded_db_adapter
end