Skip to content

Commit 9f13369

Browse files
authored
Merge pull request #3 from alexey2k/fixes.n1
Several fixes/improvements for sysbench-tpcc
2 parents ed8089c + dbd50dd commit 9f13369

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

Diff for: tpcc.lua

+6-11
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,19 @@ function event()
3535
-- print( NURand (1023,1,3000))
3636
local trx_type = sysbench.rand.uniform(1,23)
3737
if trx_type <= 10 then
38-
-- print("new_order")
39-
trx=new_order
38+
trx="new_order"
4039
elseif trx_type <= 20 then
41-
-- print("payment")
42-
trx=payment
40+
trx="payment"
4341
elseif trx_type <= 21 then
44-
-- print("order status")
45-
trx=orderstatus
42+
trx="orderstatus"
4643
elseif trx_type <= 22 then
47-
-- print("delivery")
48-
trx=delivery
44+
trx="delivery"
4945
elseif trx_type <= 23 then
50-
-- print("stock")
51-
trx=stocklevel
46+
trx="stocklevel"
5247
end
5348

5449
-- Repeat transaction execution until success
55-
while not pcall(function () trx() end ) do
50+
while not pcall(function () _G[trx]() end ) do
5651
con:query("ROLLBACK")
5752
end
5853

Diff for: tpcc_common.lua

+8-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
-- Common code for TPCC benchmarks.
1919
-- -----------------------------------------------------------------------------
2020

21+
ffi = require("ffi")
22+
23+
ffi.cdef[[
24+
void sb_counter_inc(int, sb_counter_type);
25+
]]
26+
27+
2128
function init()
2229
assert(event ~= nil,
2330
"this script is meant to be included by other TPCC scripts and " ..
@@ -337,14 +344,12 @@ function set_isolation_level(drv,con)
337344
elseif sysbench.opt.trx_level == "SER" then
338345
isolation_level="SERIALIZABLE"
339346
end
340-
347+
341348
rs=con:query("SHOW VARIABLES LIKE 't%_isolation'")
342349
row = rs:fetch_row()
343350
isolation_variable = row[1]
344351

345352
con:query("SET SESSION " .. isolation_variable .. "='".. isolation_level .."'")
346-
-- con:query("SET SESSION transaction_isolation='".. isolation_level .."'")
347-
-- con:query("SET SESSION tx_isolation='".. isolation_level .."'")
348353
end
349354
end
350355

Diff for: tpcc_run.lua

+4-3
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,11 @@ function new_order()
160160
local i_data
161161

162162
if rs.nrows == 0 then
163-
--print("ROLLBACK")
164-
con:query("ROLLBACK")
163+
--print("ROLLBACK")
164+
ffi.C.sb_counter_inc(sysbench.tid, ffi.C.SB_CNT_ERROR)
165+
con:query("ROLLBACK")
165166
return
166-
end
167+
end
167168

168169
for i = 1, rs.nrows do
169170
row = rs:fetch_row()

0 commit comments

Comments
 (0)