I'm getting the below error from mysql:
Can\'t create more than max_prepared_stmt_count statements (current value: 16382)
I've increased the value to the max (1 million) for now.
I am using node-mysql2
but I'm thinking that no matter what my prepared statement count will eventually hit 1M.
So my question is how am I supposed to properly recycle these statements so that they don't constantly hit 1M every few weeks?
Also how do I clear this cache in the meantime if I hit this 1M mark?
My node/mysql2 code is as follows:
import mysql from 'mysql2/promise'
const pool = mysql.createPool({ host, port, connectionLimit: 100 })
export default pool
I then use the pool everywhere with prepared statements a la:
pool.execute('SELECT * FROM ... etc etc')
I'm guessing holding 100 connections and reusing them is causing the prepared statements to eventually hit the max. I see an undocumented feature in node/mysql2 that says maxPreparedStatements
that I can add to the config. Will this prevent the issue in the future? Or will I still have to "clear prepared statements" in mysql every now and then (If this is the case what is the command to clear it)?
Note I have 3 replica servers that connect to mysql