-
Notifications
You must be signed in to change notification settings - Fork 21.9k
Closed
Labels
Description
I've been debugging this Solid Cache issue, and it looks like it is caused by reloading the connection class.
It is stored in the ActiveRecord::ConnectionAdapters::PoolConfig
, and if the connection class is reloaded, then
it no longer matches the stored value.
This breaks checks like this, leading to issues like the one we see in the Solid Cache bug.
You can reproduce in a development console if you are using Solid Cache like this:
>> ActiveRecord::Base.connected_to(role: ActiveRecord.reading_role, prevent_writes: true) do
SolidCache::Record.connected_to(shard: :cache, role: :writing, prevent_writes: false) do
puts SolidCache::Record.connection.preventing_writes?
end
end
false
=> nil
>> reload!
Reloading...
>> ActiveRecord::Base.connected_to(role: ActiveRecord.reading_role, prevent_writes: true) do
SolidCache::Record.connected_to(shard: :cache, role: :writing, prevent_writes: false) do
puts SolidCache::Record.connection.preventing_writes?
end
end
true
=> nil
>>
I can fix this specifically for Solid Cache by preventing SolidCache::Record
from being reloaded, but this could still be an issue for any application specific connection classes.