FATAL: mysql_stmt_prepare() failed FATAL: MySQL error: 1461 "Can't create more than max_prepared_stmt_count statements (current value: 16382)" FATAL: `thread_init' function failed: /usr/local/share/sysbench/oltp_common.lua:282: SQL API error
MySQL的错误日志信息如下:
2017-03-14T15:01:57.839154Z 348 [Note] Aborted connection 348 to db: 'sysbenchtest' user: 'root' host: 'localhost' (Got an error reading communication packets) 2017-03-14T15:01:57.839185Z 346 [Note] Aborted connection 346 to db: 'sysbenchtest' user: 'root' host: 'localhost' (Got an error reading communication packets) 看起来两者关联不大,所以有些信息就会有一些误导了。 根据错误的信息,当前的参数max_prepared_stmt_count设置值为16382,是安装后的默认值。
mysql> show variables like 'max_prepared_stmt_count'; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | max_prepared_stmt_count | 16382 | +-------------------------+-------+
而packet的参数设置为4M的样子,也是默认值
mysql> show variables like '%pack%'; +--------------------------+------------+ | Variable_name | Value | +--------------------------+------------+ | max_allowed_packet | 4194304 | | slave_max_allowed_packet | 1073741824 | +--------------------------+------------+
到底是不是参数max_allowed_packet引起的呢,我们可以简单模拟一下。
执行300个线程的时候,抓取了一下这个参数值,发现已经快溢出了。
mysql> show global status like '%stmt%'; +----------------------------+----------+ | Variable_name | Value | +----------------------------+----------+ | Prepared_stmt_count | 27300 | +----------------------------+----------+ 10 rows in set (0.00 sec)