makara
makara copied to clipboard
Check decorated connection responds to open_transactions before invoking
An ActiveRecord::Base.connection
responds to open_transactions but other connections such as a Redis client do not.
Continues from and closes https://github.com/instacart/makara/pull/324, I've also added the specs as discussed there.
As per @rosa's original PR:
We have an instance of a Makara proxy we use for Redis, for read-write splitting. It looks like this:
class RedisProxy < Makara::Proxy
# ...
def connection_for(config)
Redis.new(config)
end
# ...
end
The connection returned is an instance of a Redis client, which doesn't respond to open_transactions, so after updating to v0.5.1, any errors on Redis that would result in a Makara::Errors::BlacklistConnection, now result in a Redis::CommandError: ERR unknown command 'open_transactions'.