mariadb-corporation / mariadb-connector-nodejs

MariaDB Connector/Node.js is used to connect applications developed on Node.js to MariaDB and MySQL databases. MariaDB Connector/Node.js is LGPL licensed.
GNU Lesser General Public License v2.1
366 stars 91 forks source link

ER_MAX_PREPARED_STMT_COUNT_REACHED in batch inserts #207

Closed webigorkiev closed 1 year ago

webigorkiev commented 2 years ago

Hello

mariadb@3.0.1

When i use batch inserts or pool.batch growing Com_stmt_prepare but Com_stmt_close = 0

And then i get ER_MAX_PREPARED_STMT_COUNT_REACHED error

mariadb@2.5.6

This does not appear

Thanks

webigorkiev commented 2 years ago

Workaround

prepareCacheLength: 0

rusher commented 1 year ago

found the issue. Problem reside in prepare cache that doesn't execute close immediatly, resulting in having more cached prepare than prepareCacheLength

rusher commented 1 year ago

Current implementation use @alloc/quick-lru that evict previous cache by bulk. Cache maximum option prepareCacheLength is then not repected, because can be up to 2x that value, leading to error when reaching server max_prepared_stmt_count. After implementation verification and benchmarking, lru-cache will be the replacement, resolving the issue in next version