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

Add a size limit to the proxy's prepared statement cache #98

Open
alicel opened this issue Jan 20, 2023 · 0 comments · May be fixed by #99
Open

Add a size limit to the proxy's prepared statement cache #98

alicel opened this issue Jan 20, 2023 · 0 comments · May be fixed by #99
Assignees

Comments

@alicel
Copy link
Collaborator

alicel commented Jan 20, 2023

The proxy's PS "cache" is implemented as a map that holds known preparedIDs and a boolean indicating whether a prepared statement is a read or a write. When prepared statements are used appropriately by client applications, this should not pose any issue in terms of map size or churn.

However, it is not uncommon for client applications to misuse prepared statements. While re-preparing the same statement over and over would be harmless, a client application that does something like hardcoding parameters in the statement for every call and then prepare it would cause a different preparedId every time. This would make the map grow very large, resulting in performance degradation and high memory usage and, in the worst cases, making the the proxy crash.

To prevent this, we need to:

  • Add a test to reproduce the issue
  • Add a limit to the size of the map (this can be quite high, as the footprint of each element is very small, but at least it is not unbounded)
  • Change the PS cache maps to use an LRU cache, such as the one provided by the Hashicorp LRU library.

┆Issue is synchronized with this Jira Task by Unito
┆Components: Proxy
┆Issue Number: ZDM-522

@datastax datastax deleted a comment from sync-by-unito bot Sep 11, 2023
@joao-r-reis joao-r-reis linked a pull request Sep 11, 2023 that will close this issue
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 a pull request may close this issue.

1 participant