Skip to content

Prepared statements exceeding limits when upgrading from 0.5 to 0.6 #147

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

Closed
lucacorti opened this issue Jan 24, 2022 · 14 comments
Closed

Prepared statements exceeding limits when upgrading from 0.5 to 0.6 #147

lucacorti opened this issue Jan 24, 2022 · 14 comments

Comments

@lucacorti
Copy link

After upgrading to myxql 0.6 we saw prepared statemets constantly growing over time and exceeding the configured limit (16k)

image

while on 0.5 they are a small constant number

Screenshot 2022-01-24 at 12 44 38

@pierot
Copy link

pierot commented Jan 24, 2022

We are experiencing the exact same.

@josevalim
Copy link
Member

Thank you for the report. I am afraid this commit introduced the issue. /cc @greg-rychlewski

Can you please try running from commit: 1014f1c and see if the issue persists?

@greg-rychlewski
Copy link
Member

Hi @pierot @lucacorti ,

Do you know if you are using prepared: :named or :unnamed? Thank you

@pierot
Copy link

pierot commented Jan 24, 2022

@greg-rychlewski we don't have it set, so I guess it is :named?

@lucacorti
Copy link
Author

@josevalim We'll try using that version.

@greg-rychlewski No, we are not setting any prepared configuration.

@greg-rychlewski
Copy link
Member

greg-rychlewski commented Jan 24, 2022

@pierot @lucacorti Thanks and sorry a couple other questions:

are you using Ecto with MyXQL adapter or MyXQL directly?
- if Ecto are you issuing them with Repo.all/Repo.one, etc or with Ecto.Adapters.SQL.query?
- if MyXQL how are you calling the queries

@lucacorti
Copy link
Author

@greg-rychlewski We are mostly using myxql via the Ecto adapter with Repo.all/one

@pierot
Copy link

pierot commented Jan 24, 2022

@greg-rychlewski Only using Ecto with MyXQL adapter and Repo.all.

@lucacorti
Copy link
Author

@josevalim looks like it's working with 1014f1c:

> SHOW GLOBAL STATUS LIKE '%prepared_stmt_count%';
+---------------------+-------+
| Variable_name       | Value |
+---------------------+-------+
| Prepared_stmt_count | 0     |
+---------------------+-------+
1 row in set
Time: 0.113s

@lucacorti
Copy link
Author

No, sorry, I was on the wrong node, still having problems with prepared statements growing indefinitely even with that version.

@josevalim
Copy link
Member

@lucacorti @pierot can you please try master? I have reverted both commits that could have caused this.

@greg-rychlewski
Copy link
Member

greg-rychlewski commented Jan 24, 2022

@josevalim I have an idea what the issue could be. But it's difficult for me to set up the environment needed right now.

In multi-node setups prepared statements with the same name can be saved with different refs. If it was prepared on one node then executed on another it will be re-prepared and the next time it's executed on the original node, the refs won't match and it will be re-prepared again.

Before the cache change commit, executions would check for the name and not the ref. So each node would only be able to re-prepare an existing statement once. If it went back to checking for name instead of ref I believe this issue should disappear.

@lucacorti
Copy link
Author

@josevalim I'm running latest master in production, seems to behave like 0.5.2.

@josevalim
Copy link
Member

Thank you! v0.6.1 is out!

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

4 participants