TLDR: I would like to backport https://github.com/rails/rails/pull/35089 (“Invalidate all query caches for current thread”) to 5.2-stable branch.
The issue comes from this patch which enables query cache for all connection pools - https://github.com/rails/rails/pull/28869.
active_record_slave to read some records from slave database. It uses special abstract model which connects to slave database using
establish_connection and all reads go through this model by default.
My case (consider this happens inside http request/response cycle):
- fetch some record - it will be read from slave and this query will be cached
- delete that record - this query will go through
AR::Base.connection_poolto master database and this will clear the cache for this connection pool but not for connection pool of the model for slave database.
- fetch the same record from step №1 using the same query - this will return the record from cache, because all reads go to slave by default.
AR.uncachedcannot be used because it works only for
Can I make a backport?