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

Flowmachine fails to invalidate cache if redis is not in sync #6484

Open
jc-harrison opened this issue Mar 27, 2024 · 0 comments
Open

Flowmachine fails to invalidate cache if redis is not in sync #6484

jc-harrison opened this issue Mar 27, 2024 · 0 comments
Labels
bug Something isn't working FlowMachine Issues related to FlowMachine

Comments

@jc-harrison
Copy link
Member

If the flowmachine query locker (redis) has somehow got out of sync with the state of the flowmachine query cache in FlowDB, so that a cached query is in known state, then query.invalidate_db_cache() will silently fail to remove the cache table (because query_state_machine.reset() has no effect on a query in known state).

A side effect of this is that flowmachine.core.cache.shrink_below_size reports (in log messages) that the cache is shrinking even if it isn't, because it assumes a successful invalidate_query_by_id run means that the cache table has been dropped and subtracts the table size from its internal record of the cache size, and does not check for cache table existence or re-fetch the cache size from FlowDB between query drops.

I think there are a few issues here:

  • query.is_stored (which does not touch redis, and directly checks the DB for the corresponding cache table) should always be the source of truth for checking whether a cache record exists
  • query.invalidate_db_cache() should raise an error if query.is_stored is still True at the end (if drop=True)
  • I can't think of a good reason not to allow QueryStateMachine.reset() to reset from known state as well, which would mean an existing cache entry could be cleared even if there's no corresponding query state in redis
  • flowmachine.core.cache.shrink_below_size shouldn't report the cache size as having shrunk if the cache table wasn't actually dropped - I think this should be covered by the above points (i.e. as long as query.invalidate_db_cache() raises an error if the cache table still exists at the end, then shrink_below_size can trust that the table has been removed).
@jc-harrison jc-harrison added bug Something isn't working FlowMachine Issues related to FlowMachine labels Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working FlowMachine Issues related to FlowMachine
Projects
None yet
Development

No branches or pull requests

1 participant