File tree Expand file tree Collapse file tree 3 files changed +18
-17
lines changed
Expand file tree Collapse file tree 3 files changed +18
-17
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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+
2128function 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
349354end
350355
Original file line number Diff line number Diff 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 ()
You can’t perform that action at this time.
0 commit comments