-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aks/sync query cache changes #19
base: main
Are you sure you want to change the base?
Conversation
…onnection into aks/sync-query-cache-changes
Thank you for showing the problem raising and solving method. |
aa79f93
to
29d4a30
Compare
3bf0c11
to
50a20ae
Compare
Hi Tsukasa-san, ひさしぶりですね。 Have you considered how to maintain cache-coherency in the replica caches when master-writes occur? |
Hello Mr.Stebbens. Good to see you again. |
This PR adds support for syncing query cache changes from the master connection cache to the replica query caches.
The new test script confirms that a cache syncing problems exists, with
replica_query_cache_sync
disabled, and then confirms that the problem does not occur whenreplica_query_cache_sync
is enabled.The feature is controlled by a class variable
@@replica_query_cache_sync
that is false by default -- in order to maintain backward compatibility and not provide any query cache behavior by default.This PR was tested with the support for
fake_replica
enabled, which has been submitted as a separate PR.Note: this PR supports both Rails 4.2+ and Rails 5
Also: I'm not happy with this PR as it currently stands. I wanted to show the problem, and a solution, but am not sure that this is the Right solution.
For example, I think query cache syncing should turn on automatically if query caching is enabled. What value would there be in not syncing when query caching is enabled?
Also, the tests pass most of the time, but once in a while, one of the tests fail, with the symptom of a recursive loop starting with the
clear_query_cache
method. Due to other urgencies, haven't had time to dig in a identify the root cause of this infrequent, spurious test failure.Lastly, there needs to be a way to select the appropriate corresponding replica connection pool from any given master connection -- so that when the master connection invokes
clear_query_cache
(after anupdate
orinsert
on that connection), it is easy (low-cost) to also triggerclear_query_cache
on the replica connections in the replica connection pool.