作者:晓亮居士_264 | 来源:互联网 | 2023-09-09 19:00
usrsysbenchbinsysbenchusrsysbenchsharesysbencholtp_write_only.lua–mysql-userroot–mys
/usr/sysbench/bin/sysbench /usr/sysbench/share/sysbench/oltp_write_only.lua –mysql-user=root –mysql-password=xxx –mysql-port=3334 –mysql-host=xxxx –mysql-db=test –table-size=5000000 –tables=1 –threads=100 run
在使用上面的命令向一个表中并发100插入数据的时候,提示主键冲突,表开始的自增是1,表中的数据实际插入了1w多,但是id分配已经分配了390w
FATAL: mysql_stmt_execute() returned error 1062 (Duplicate entry ‘2491570’ for key ‘PRIMARY’) for query ‘INSERT INTO sbtest1 (id, k, c, pad) VALUES (?, ?, ?, ?)’
FATAL: `thread_run’ function failed: ./oltp_common.lua:484: SQL error, errno = 1062, state = ‘23000’: Duplicate entry ‘2491570’ for key ‘PRIMARY’
Error in my_thread_global_end(): 1 threads didn’t exit
1 row in set (0.01 sec)
| sbtest1 | CREATE TABLE `sbtest1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`k` int(11) NOT NULL DEFAULT '0',
`c` char(120) NOT NULL DEFAULT '',
`pad` char(60) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `k_1` (`k`)
1 row in set (0.00 sec)
| innodb_autoextend_increment | 64 |
2 rows in set (0.02 sec)
真正遇到高并发写入的情况,本次测试的并发写入是有删除,插入等操作,还是考虑别的实现吧,应用生成,只有插入的操作,这个并发是没有问题的