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

maximum prepared statements issue #116

Open
metacortex opened this issue Sep 28, 2017 · 4 comments
Open

maximum prepared statements issue #116

metacortex opened this issue Sep 28, 2017 · 4 comments

Comments

@metacortex
Copy link
Contributor

In crystal-db, prepared statements are only closed when the connection is closed.

When it reach the max value, it raises exception

Error: Can't create more than max_prepared_stmt_count statements (current value: 16382)

crystal-lang/crystal-db#60
It is recommended that close the connection and open the new one.

Do you have idea to solve this issue?

Currently I exposed Repo::Config and close/open new connection manually in the loop which inserts millions of rows.

@fridgerator
Copy link
Member

Interesting I didn't know about this, I'll have to research it further.

Do you have any ideas?

@metacortex
Copy link
Contributor Author

metacortex commented Sep 28, 2017

I am just creating the new connection every 10k bulk inserts.
https://github.com/metacortex/crecto/tree/reset_connection

Manually calling Repo.reset_connection in the end of every loop.
It's little bit ugly but works well for my case.

@fridgerator
Copy link
Member

@metacortex there have been a few commits to crystal-db since 0.4.2 related to this, is the problem fixed if you use crystal-db master?

@metacortex
Copy link
Contributor Author

@fridgerator No. It just releases the existing connection to prevent leaking. crystal-db raises exception, and handling it should be done outside of crystal-db.

Crecto would handle the exception (re-open connection when this kind of exception caught),
or let users handle it. (need to expose access method to db connection instance)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants