相关的学习资料
https://www.jianshu.com/p/30933e0bebe7
【系统版本 & kernel 版本】
CentOS Linux release 7.6.1810 (Core)
4.20.10-1.el7.elrepo.x86_64
【sysbench 版本】
sysbench 1.0.17 (using system LuaJIT 2.0.4)
【场景】
使用 sysbench 根据业务场景做迭代更新, 的压力测试
数据库表
CREATE TABLE `table_1` (
`id` int(11) NOT NULL,
`username` varchar(255) DEFAULT NULL,
`city` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
自定义测试脚本: update.lua
#!/usr/bin/env sysbench
-- 执行 run 命令 触发的函数(开始压测),也就是真正开启事务进行压测的函数
function event()
-- 连接数据库
local drv = sysbench.sql.driver()
local con = drv:connect()
while (true)
do
con:query("BEGIN")
local result = con:query(" UPDATE table_1 SET username= 'tug666' WHERE city = '大连市' limit 5000 ")
con:query("COMMIT")
if result.row <= 0 then
break;
end
end
end
【问题描述(我做了什么)】
sysbench --config-file=config update.lua run
[tidb@test tidb-tools]$ sysbench --config-file=config update.lua run
sysbench 1.0.17 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 16
Report intermediate results every 10 second(s)
Initializing random number generator from current time
Initializing worker threads...
Threads started!
FATAL: `thread_run' function failed: update.lua:15: attempt to compare 'struct 167' with 'number'
Error in my_thread_global_end(): 1 threads didn't exit
[tidb@test tidb-tools]$
【我的期望】
result.row 能够返回,每次更新受影响的行数。