-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Allow prepared_statements_cache=false option to disable prepared statements cache #194
Conversation
Override crystal-sqlite3 dependency on DB to help test crystal-lang/crystal-db#194
Allow to define at runtime which database configuration to use but keep some sensitive defaults. This helps with testing `prepared_statements_cache=false` functionality introduced by crystal-lang/crystal-db#194
Hello @bcardiff, while I'm working on some updated benchmarks in https://github.com/luislavena/test-crystal-sqlite3-db, I found that disabling the statement cache breaks proper cleanup of the statements in memory, raising exception when attempt to close the connections:
This happens on both single-thread and Let me know if this is not correct as I understand that Thank you. |
Oh. Disabling it for the pool, the last commit might have been to much. When using the pool, and not s connection directly, there is always 2 prepared. The first one checks out a connection to validate the statement can be prepared. And then when executing the statement another might be used. By disabling the cache in the pool I think we prevent the cleanup. Will check if there is way around that or if the cache should not be disabled at the pool. |
Ok, it's not just the pool statement. We need to release every prepared statement after using it if we are not caching it. The cache served also for tracking those resources and cleaning it up before the connection where closed. Would be better to eager release right after using them or delaying that until the connection is no longer needed? I guess eager, but either can work. |
During #178 we came up that it would be nice to be able to tweak whether the prepared statements are cached or not. This option allows the user to opt-out of the statement cache, while still use prepared statements. Some drivers only allow prepared statements.
cc: @luislavena