mijia / modelq

ModelQ is a code generator for creating Golang codes/models to access RDBMS database/tables
MIT License
294 stars 40 forks source link

Prepared statements should close #32

Closed richhx closed 7 years ago

richhx commented 7 years ago

Prepare statements are leaking whenever an UPDATE is made. The statements are getting closed for queries (q _Query) query(...)but not for any updates made (q _Query) exec(...) see modelq/gmq/package.go. The prepares get deallocated whenever the connection disappears, but in the case that the connection persists and many updates are being done via transactions, we will eventually hit the maximum number of prepared statements (which by default is 13682) and receive error 1461. This shouldn't happen. A workaround would be to increase the limit, but the preferred way would be to close the statement when it's finished.

https://dev.mysql.com/doc/refman/5.7/en/server-status-variables.html#statvar_Prepared_stmt_count

mijia commented 7 years ago

Thank you very much. The PR has been merged.