Skip to content

Commit 9d6070a

Browse files
authored
Merge pull request #1 from alexey2k/master
Various fixes
2 parents 1b0cf0d + 3f58785 commit 9d6070a

File tree

2 files changed

+38
-31
lines changed

2 files changed

+38
-31
lines changed

tpcc.lua

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,35 +26,33 @@ function thread_init()
2626
drv = sysbench.sql.driver()
2727
con = drv:connect()
2828

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
29+
set_isolation_level(drv,con)
30+
3931
end
4032

4133
function event()
4234
-- print( NURand (1023,1,3000))
43-
local trx = sysbench.rand.uniform(1,23)
44-
if trx <= 10 then
45-
new_order()
46-
elseif trx <= 20 then
47-
payment()
48-
elseif trx <= 21 then
35+
local trx_type = sysbench.rand.uniform(1,23)
36+
if trx_type <= 10 then
37+
-- print("new_order")
38+
trx=new_order
39+
elseif trx_type <= 20 then
40+
-- print("payment")
41+
trx=payment
42+
elseif trx_type <= 21 then
4943
-- print("order status")
50-
orderstatus()
51-
elseif trx <= 22 then
52-
-- print("delivery")
53-
delivery()
54-
elseif trx <= 23 then
55-
-- print("delivery")
56-
stocklevel()
44+
trx=orderstatus
45+
elseif trx_type <= 22 then
46+
-- print("delivery")
47+
trx=delivery
48+
elseif trx_type <= 23 then
49+
-- print("stock")
50+
trx=stocklevel
5751
end
52+
53+
-- Repeat transaction execution until success
54+
while not pcall(function () trx() end ) do end
55+
5856
end
5957

6058
-- vim:ts=4 ss=4 sw=4 expandtab

tpcc_common.lua

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -324,24 +324,33 @@ function create_tables(drv, con, table_num)
324324

325325
end
326326

327-
function load_tables(drv, con, warehouse_num)
328-
local id_index_def, id_def
329-
local engine_def = ""
330-
local extra_table_options = ""
331-
local query
332327

328+
function set_isolation_level(drv,con)
333329
if drv:name() == "mysql"
334330
then
335331
if sysbench.opt.trx_level == "RR" then
336-
con:query("SET SESSION transaction_isolation='REPEATABLE-READ'")
332+
isolation_level="REPEATABLE-READ"
337333
elseif sysbench.opt.trx_level == "RC" then
338-
con:query("SET SESSION transaction_isolation='READ-COMMITTED'")
334+
isolation_level="READ-COMMITTED"
339335
elseif sysbench.opt.trx_level == "SER" then
340-
con:query("SET SESSION transaction_isolation='SERIALIZABLE'")
336+
isolation_level="SERIALIZABLE"
341337
end
338+
339+
con:query("SET SESSION transaction_isolation='".. isolation_level .."'")
340+
-- con:query("SET SESSION tx_isolation='".. isolation_level .."'")
342341
end
342+
end
343343

344344

345+
346+
function load_tables(drv, con, warehouse_num)
347+
local id_index_def, id_def
348+
local engine_def = ""
349+
local extra_table_options = ""
350+
local query
351+
352+
set_isolation_level(drv,con)
353+
345354
-- print(string.format("Creating warehouse: %d\n", warehouse_num))
346355

347356
for table_num = 1, sysbench.opt.tables do

0 commit comments

Comments
 (0)