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

Use the prepare cache to prepare on node add/up events #32

Open
mpenick opened this issue Sep 2, 2021 · 4 comments
Open

Use the prepare cache to prepare on node add/up events #32

mpenick opened this issue Sep 2, 2021 · 4 comments

Comments

@mpenick
Copy link
Contributor

mpenick commented Sep 2, 2021

When adding a new node or restarting node its prepared cache is empty. This causes execution of prepare queries to fail with unprepared errors. We handle this at the proxy-level by handling unprepared errors with preparing the queries on the executing connection and re-executing the original request. This results in extra latency and it can cause a "stampeding herd" of preparing on the new node. To mitigate these issues we can prepare new and newly restarted nodes with the queries that are in the proxy's prepared cache before marking the node as available.

@prabhatjha
Copy link

Where is the prepared cache stored? Also usual cache concerns like TTL, size ?

@prabhatjha
Copy link

I think I am going to answer my question. :-) It's proxy's in-memory prepared cache. However, I would still like to understand TTL, size so that we don't go OOM because of that.

@mpenick
Copy link
Contributor Author

mpenick commented Sep 2, 2021

It lives in the proxy. It's currently infinite on both accounts. This sounds terrible, but in practice it's not as bad as it sounds because it tends to be really small (even with many entries). That said, I have an idea to make this more robust, but it might be overkill.

@mpenick
Copy link
Contributor Author

mpenick commented Sep 2, 2021

Sized capped at ~100MB: 147ef72

mpenick added a commit that referenced this issue Sep 3, 2021
In the existing code execute queries were just a pass-through. That means that
if an unprepared error occurred it was just passed back to the driver. The
problem is that an attempt to prepare that query again would be forwarded to a
connection that was not the one that originally serviced the execute. This
could cause a scenario where execute requests would never resolve from the
unprepared state.

The proxy fixes this by keeping its own cache and properly handling unprepared
errors. This cache was push down into the `proxycore` because eventually we
should add pre-preparing queries on add/up node events. This should be address
in a follow up issue: #32
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

No branches or pull requests

2 participants