Skip to content
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

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

aks
Copy link
Contributor

@aks aks commented Jun 6, 2017

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 when replica_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 an update or insert on that connection), it is easy (low-cost) to also trigger clear_query_cache on the replica connections in the replica connection pool.

@tsukasaoishi
Copy link
Owner

Thank you for showing the problem raising and solving method.
I also think that I need to think about this problem properly.
I m thinking about solutions to Rails 5.1 as well.
Please give me some time.

@aks
Copy link
Contributor Author

aks commented Aug 30, 2019

Hi Tsukasa-san, ひさしぶりですね。

Have you considered how to maintain cache-coherency in the replica caches when master-writes occur?

@tsukasaoishi
Copy link
Owner

Hello Mr.Stebbens. Good to see you again.
QueryCache problem has already been solved.

Base automatically changed from master to main January 19, 2021 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants