Skip to content

Conversation

@weiznich
Copy link
Owner

@weiznich weiznich commented Nov 7, 2025

This change refactors how we close uncached mysql statements. Instead of trying to issue the close request as part of the same SQL query, we now just keep track of whether a statement need to be closed or not and execute the closing as first operation in the next query execution. The large advantage of this approach is that we sidestep any async drop/cancelation related problems. The disadvantage is that we keep that statement open for a bit longer. I cannot see how we ever would have more than one statement in there per connection and we also keep the cached statements around, so this shouldn't cause any problems in practice.

Fix #269
Closes #270

cc @lukezbihlyj I think this is a better solution than polling the whole stream for all backends

This change refactors how we close uncached mysql statements. Instead of
trying to issue the close request as part of the same SQL query, we now
just keep track of whether a statement need to be closed or not and
execute the closing as first operation in the next query execution. The
large advantage of this approach is that we sidestep any async
drop/cancelation related problems. The disadvantage is that we keep that
statement open for a bit longer. I cannot see how we ever would have
more than one statement in there per connection and we also keep the
cached statements around, so this shouldn't cause any problems in
practice.

Fix #269
@weiznich weiznich merged commit 65d3f33 into main Nov 7, 2025
24 checks passed
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 this pull request may close these issues.

MySQL non-cacheable queries leak into the prepared statement cache eventually filling it up

2 participants