Skip to content

Bugfix: Implement transaction locks in cache invalidate#124

Merged
spiritix merged 1 commit intospiritix:masterfrom
MGApcDev:bugfix/implement-transaction-locks-in-cache-invalidate
Feb 1, 2024
Merged

Bugfix: Implement transaction locks in cache invalidate#124
spiritix merged 1 commit intospiritix:masterfrom
MGApcDev:bugfix/implement-transaction-locks-in-cache-invalidate

Conversation

@MGApcDev
Copy link
Copy Markdown

Sometimes stale cache never purged in distributed system (race condition)

In bigger systems with a lot of traffic there is a chance that a cache is stuck in the stale state.


Bug scenario:

  1. User performs query that triggers the invalidation of a model cache on "tag2"
  2. Process 1; fetches hashes for a tag "tag2"
  3. Another user performs query that triggers caching of data.
  4. Process 2; adds cache for "key3",
  5. Process 2; adds additional key "key3" to tag "tag2"
  6. Process 1; deletes all hashes it found in tag "tag2"
  7. Process 1; deletes cache tag "tag2"

Expected outcome:

  • There should be a cache for "key3"
  • There should be a cache for "tag2" containing "key3"

Actual outcome:

  • There is a cache for "key3"
  • There is NOT a cache for "tag2"

Issue:

  • This is a problem, because the cache for "key3" will still be used by fetch queries, but going forward calls to invalidate "tag2" does not clear "key3".
  • "key3" cache will say until the cache hits it's expire time.

I've tried to add a test that simulates the issue case, but it happens between 2 private method calls, so it's a little hard to write.

…ng tag

Keep functions private, but make a reflection class in test to call the private methods

Add comments to code

Rename test function
@spiritix spiritix merged commit fea7856 into spiritix:master Feb 1, 2024
@spiritix
Copy link
Copy Markdown
Owner

spiritix commented Feb 1, 2024

Thanks for your contribution, highly appreciated!

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.

3 participants