Open lylth opened 2 years ago
This appears to be a real issue, but to me it seems to be with luajit. I have exactly the same issue.
I have added the print statement as diagnostic code to the routine cmd_prepare in oltp_common.lua:
for i = sysbench.tid % sysbench.opt.threads + 1, sysbench.opt.tables,
sysbench.opt.threads do
print(string.format("creating table i %d, tid %d, threads %d, tables %d", i, sysbench.tid, sysbench.opt.threads, sysbench.opt.tables))
create_table(drv, con, i)
end
When the test runs, the following is output:
sysbench 1.0.20-ebf1c90 (using system LuaJIT 2.1.0-beta3)
creating table i 1, tid 0, threads 1, tables 30
Creating table 'sbtest1'...
Inserting 600000 records into 'sbtest1'
Creating a secondary index on 'sbtest1'...
creating table i 2, tid 0, threads 1, tables 30
Creating table 'sbtest2'...
Inserting 600000 records into 'sbtest2'
Creating a secondary index on 'sbtest2'...
creating table i 3, tid 0, threads 1, tables 30
Creating table 'sbtest3'...
Inserting 600000 records into 'sbtest3'
Creating a secondary index on 'sbtest3'...
creating table i 4, tid 0, threads 1, tables 30
Creating table 'sbtest4'...
Inserting 600000 records into 'sbtest4'
Creating a secondary index on 'sbtest4'...
creating table i 5, tid 0, threads 1, tables 30
Creating table 'sbtest5'...
Inserting 600000 records into 'sbtest5'
Creating a secondary index on 'sbtest5'...
creating table i 6, tid 0, threads 1, tables 30
Creating table 'sbtest6'...
Inserting 600000 records into 'sbtest6'
Creating a secondary index on 'sbtest6'...
creating table i 7, tid 0, threads 1, tables 30
Creating table 'sbtest7'...
Inserting 600000 records into 'sbtest7'
Creating a secondary index on 'sbtest7'...
creating table i 8, tid 0, threads 1, tables 30
Creating table 'sbtest8'...
Inserting 600000 records into 'sbtest8'
Creating a secondary index on 'sbtest8'...
creating table i 9, tid 0, threads 1, tables 30
Creating table 'sbtest9'...
Inserting 600000 records into 'sbtest9'
Creating a secondary index on 'sbtest9'...
creating table i 10, tid 0, threads 1, tables 30
Creating table 'sbtest10'...
Inserting 600000 records into 'sbtest10'
Creating a secondary index on 'sbtest10'...
creating table i 11, tid 0, threads 1, tables 30
Creating table 'sbtest11'...
Inserting 600000 records into 'sbtest11'
Creating a secondary index on 'sbtest11'...
creating table i 12, tid 0, threads 1, tables 30
Creating table 'sbtest12'...
Inserting 600000 records into 'sbtest12'
Creating a secondary index on 'sbtest12'...
creating table i 2, tid 0, threads 1, tables 30
Creating table 'sbtest2'...
FATAL: mysql_drv_query() returned error 1050 (Table 'sbtest2' already exists) for query 'CREATE TABLE sbtest2(
id INTEGER NOT NULL AUTO_INCREMENT,
k INTEGER DEFAULT '0' NOT NULL,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) /*! ENGINE = innodb */ '
FATAL: `sysbench.cmdline.call_command' function failed: ./src/lua/oltp_common.lua:198: SQL error, errno = 1050, state = '42S01': Table 'sbtest2' already exists
sysbench 1.0.20-ebf1c90 (using system LuaJIT 2.1.0-beta3)
Yes, in fact sbtest2 does already exist. That's because the loop already created it. For some reason, the loop iteration failed. It came up with "2" rather than "13" as it should. My knowledge of lua is very limited but the statement:
for i = sysbench.tid % sysbench.opt.threads + 1, sysbench.opt.tables,
sysbench.opt.threads do
Where sysbench.tid = 0, sysbench.opt.threads = 1, and sysbench.opt.tables=30 should go from 1 through 30. It should not go from 1 to 12 and then to 2. What happened to 13?
It’s a Lua bug. I rewrote the loop and the issue goes away. Changed it from:
for i = sysbench.tid % sysbench.opt.threads + 1, sysbench.opt.tables, sysbench.opt.threads do
create_table(drv, con, i)
end
to:
local i = sysbench.tid % sysbench.opt.threads +1
while (true) do
if i > sysbench.opt.tables then
break
end
create_table(drv, con, i)
i = i + sysbench.opt.threads
end
and it works.
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2) mysql5.7 aarch64 CentOS Linux release 7.6.1810 (AltArch)
sysbench --db-driver=mysql --mysql-host=xxxx --mysql-port=3306 --mysql-user=root --mysql-password=xxxxxx --mysql-socket=/stonedb57/install/tmp/mysql.sock --mysql-db=xxx --table_size=800 --tables=100 --time=600 --create_secondary=false --threads=1 --mysql_storage_engine=stonedb /usr/share/sysbench/oltp_read_only.lua prepare