Skip to content

Commit 1b0cf0d

Browse files
committed
added isolation levels
1 parent 3e6b860 commit 1b0cf0d

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ TPCC-like workload for sysbench
88
./tpcc.lua --mysql-socket=/tmp/mysql.sock --mysql-user=root --mysql-db=sbt --time=300 --threads=64 --report-interval=1 --tables=10 --scale=100 prepare
99
`
1010

11+
## prepare for RocksDB
12+
13+
`
14+
./tpcc.lua --mysql-socket=/tmp/mysql.sock --mysql-user=root --mysql-db=sbr --time=3000 --threads=64 --report-interval=1 --tables=10 --scale=100 --use_fk=0 --mysql_storage_engine=rocksdb --mysql_table_options='COLLATE latin1_bin' --trx_level=RC prepare
15+
`
16+
1117
# Run benchmark
1218

1319
`

tpcc.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,21 @@ require("tpcc_common")
2222
require("tpcc_run")
2323
require("tpcc_check")
2424

25+
function thread_init()
26+
drv = sysbench.sql.driver()
27+
con = drv:connect()
28+
29+
if drv:name() == "mysql"
30+
then
31+
if sysbench.opt.trx_level == "RR" then
32+
con:query("SET SESSION transaction_isolation='REPEATABLE-READ'")
33+
elseif sysbench.opt.trx_level == "RC" then
34+
con:query("SET SESSION transaction_isolation='READ-COMMITTED'")
35+
elseif sysbench.opt.trx_level == "SER" then
36+
con:query("SET SESSION transaction_isolation='SERIALIZABLE'")
37+
end
38+
end
39+
end
2540

2641
function event()
2742
-- print( NURand (1023,1,3000))

tpcc_common.lua

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ sysbench.cmdline.options = {
4040
{"Number of tables", 1},
4141
use_fk =
4242
{"Use foreign keys", 1},
43+
trx_level =
44+
{"Transaction isolation level (RC, RR or SER)", "RR"},
4345
mysql_storage_engine =
4446
{"Storage engine, if MySQL is used", "innodb"},
4547
mysql_table_options =
@@ -328,18 +330,23 @@ function load_tables(drv, con, warehouse_num)
328330
local extra_table_options = ""
329331
local query
330332

331-
if drv:name() == "mysql" or drv:name() == "attachsql" or
332-
drv:name() == "drizzle"
333+
if drv:name() == "mysql"
333334
then
334-
engine_def = "/*! ENGINE = " .. sysbench.opt.mysql_storage_engine .. " */"
335+
if sysbench.opt.trx_level == "RR" then
336+
con:query("SET SESSION transaction_isolation='REPEATABLE-READ'")
337+
elseif sysbench.opt.trx_level == "RC" then
338+
con:query("SET SESSION transaction_isolation='READ-COMMITTED'")
339+
elseif sysbench.opt.trx_level == "SER" then
340+
con:query("SET SESSION transaction_isolation='SERIALIZABLE'")
341+
end
335342
end
336343

337344

338345
-- print(string.format("Creating warehouse: %d\n", warehouse_num))
339346

340347
for table_num = 1, sysbench.opt.tables do
341348

342-
print(string.format("Creating tables: %d for warehouse: %d\n", table_num, warehouse_num))
349+
print(string.format("loading tables: %d for warehouse: %d\n", table_num, warehouse_num))
343350

344351
con:bulk_insert_init("INSERT INTO warehouse" .. table_num ..
345352
" (w_id, w_name, w_street_1, w_street_2, w_city, w_state, w_zip, w_tax, w_ytd) values")

0 commit comments

Comments
 (0)