I followed the instructions in this Percona article carefully.
I was able to prepare the database fine, but when I tried to run it, it throws an error.
[root@ha57b sysbench-tpcc-2.2]# ./tpcc.lua --mysql-socket=/fs/site622/mysqld/mysqld.sock --mysql-user=root --mysql-password=xxxxxxxxx --mysql-db=tpcc --threads=16 --time=7200 --report-interval=10 --tables=10 --scale=200 --db-driver=mysql run
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
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: ./tpcc_run.lua:721: bad argument #1 to ‘unpack’ (table expected, got nil)
[root@ha57b sysbench-tpcc-2.2]#
I have tried it on Percona Server 8.0.32.and 8.4.4. The Linux distro is Rocky 9.
--[[
SELECT COUNT(DISTINCT (s_i_id)) INTO :stock_count
FROM order_line, stock
WHERE ol_w_id=:w_id AND ol_d_id=:d_id AND ol_o_id<:o_id AND ol_o_id>=:o_id-20 AND s_w_id=:w_id AND s_i_id=ol_i_id AND s_quantity < :threshold;
--]]
rs = con:query(([[SELECT COUNT(DISTINCT (s_i_id))
FROM order_line%d, stock%d
WHERE ol_w_id = %d
AND ol_d_id = %d
AND ol_o_id < %d
AND ol_o_id >= %d
AND s_w_id= %d
AND s_i_id=ol_i_id
AND s_quantity < %d ]])
:format(table_num, table_num, w_id, d_id, d_next_o_id, d_next_o_id - 20, w_id, level ))
-- SELECT DISTINCT ol_i_id
-- FROM order_line
I don’t see a call to unpack() on line 721. Are you using the latest version of tpcc-sysbench?
I’m using sysbench-tpcc-2.2.zip, downloaded from Releases · Percona-Lab/sysbench-tpcc · GitHub .
However, my lines look way different that yours.
711 else
712
713 rs = con:query(([[SELECT DISTINCT ol_i_id FROM order_line%d
714 WHERE ol_w_id = %d AND ol_d_id = %d
715 AND ol_o_id < %d AND ol_o_id >= %d]])
716 :format(table_num, w_id, d_id, d_next_o_id, d_next_o_id - 20 ))
717
718 local ol_i_id
719
720 for i = 1, rs.nrows do
721 ol_i_id = unpack(rs:fetch_row(), 1, rs.nfields)
722
723
724 – SELECT count() INTO :i_count
725 – FROM stock
726 – WHERE s_w_id = :w_id
727 – AND s_i_id = :ol_i_id
728 – AND s_quantity < :level; /
729
730 rs1 = con:query(([[SELECT count(*) FROM stock%d
731 WHERE s_w_id = %d AND s_i_id = %d
I just confirmed that the source code in the zip file is NOT the same as the source code in the listing.
Okay, I replaced tpcc_run.lua with the source from the link you gave me and it worked. That means the downloadable zip file has the wrong contents,