active_record_host_pool 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5238d6f59f78811a9e9972e613562d674d1137604438b46d0ef3b9a3eb1fa437
|
4
|
+
data.tar.gz: 937e6d46772dc13b3b6faa62841053252aae17f92f8ef205b63927345408ed65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdbd8abf041ad7960996bbd0432fc19c90c0ae0c41328069798c401929cca9c3b9dd510f7160ab833895962b12e86937bf8eb592d851bea2197b94fcdf57b95a
|
7
|
+
data.tar.gz: '068fff2a8be21b0e1ca192a49967c352d90b5c81aae27c11f36128ec825b4c03a9087f56269b10ca2cf406ddea445dc48662110284f1a3870eb4d48df0ceba7b'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if ActiveRecord.version >= Gem::Version.new('6.0')
|
4
|
+
module ActiveRecordHostPool
|
5
|
+
# ActiveRecord 6.0 introduced multiple database support. With that, an update
|
6
|
+
# has been made in https://github.com/rails/rails/pull/35089 to ensure that
|
7
|
+
# all query caches are cleared across connection handlers and pools. If you
|
8
|
+
# write on one connection, the other connection will have the update that
|
9
|
+
# occurred.
|
10
|
+
#
|
11
|
+
# This broke ARHP which implements its own pool, allowing you to access
|
12
|
+
# multiple databases with the same connection (e.g. 1 connection for 100
|
13
|
+
# shards on the same server).
|
14
|
+
#
|
15
|
+
# This patch maintains the reference to the database during the cache clearing
|
16
|
+
# to ensure that the database doesn't get swapped out mid-way into an
|
17
|
+
# operation.
|
18
|
+
#
|
19
|
+
# This is a private Rails API and may change in future releases as they're
|
20
|
+
# actively working on sharding in Rails 6 and above.
|
21
|
+
module ClearQueryCachePatch
|
22
|
+
def clear_query_caches_for_current_thread
|
23
|
+
host_pool_current_database_was = connection.unproxied._host_pool_current_database
|
24
|
+
super
|
25
|
+
ensure
|
26
|
+
# restore in case clearing the cache changed the database
|
27
|
+
connection.unproxied._host_pool_current_database = host_pool_current_database_was
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
ActiveRecord::Base.singleton_class.prepend ActiveRecordHostPool::ClearQueryCachePatch
|
33
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_host_pool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Quorning
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- MIT-LICENSE
|
146
146
|
- Readme.md
|
147
147
|
- lib/active_record_host_pool.rb
|
148
|
+
- lib/active_record_host_pool/clear_query_cache_patch.rb
|
148
149
|
- lib/active_record_host_pool/connection_adapter_mixin.rb
|
149
150
|
- lib/active_record_host_pool/connection_proxy.rb
|
150
151
|
- lib/active_record_host_pool/pool_proxy.rb
|