OLTP scripts: add --reconnect option.
oltp_*.lua scripts now support the --reconnect=N option. When specified, sysbench will reconnect after every N events. Fixes GH-90.
This commit is contained in:
@ -68,6 +68,9 @@ sysbench.cmdline.options = {
|
||||
{"Use a secondary index in place of the PRIMARY KEY", false},
|
||||
create_secondary =
|
||||
{"Create a secondary index in addition to the PRIMARY KEY", true},
|
||||
reconnect =
|
||||
{"Reconnect after every N events. The default (0) is to not reconnect",
|
||||
0},
|
||||
mysql_storage_engine =
|
||||
{"Storage engine, if MySQL is used", "innodb"},
|
||||
pgsql_variant =
|
||||
@ -505,3 +508,14 @@ function sysbench.hooks.before_restart_event(errdesc)
|
||||
prepare_statements()
|
||||
end
|
||||
end
|
||||
|
||||
function check_reconnect()
|
||||
if sysbench.opt.reconnect > 0 then
|
||||
transactions = (transactions or 0) + 1
|
||||
if transactions % sysbench.opt.reconnect == 0 then
|
||||
close_statements()
|
||||
con:reconnect()
|
||||
prepare_statements()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -31,4 +31,6 @@ function event()
|
||||
|
||||
param[tnum].deletes[1]:set(id)
|
||||
stmt[tnum].deletes:execute()
|
||||
|
||||
check_reconnect()
|
||||
end
|
||||
|
||||
@ -62,4 +62,6 @@ function event()
|
||||
"(%d, %d, '%s', '%s')",
|
||||
table_name, i, k_val, c_val, pad_val))
|
||||
end
|
||||
|
||||
check_reconnect()
|
||||
end
|
||||
|
||||
@ -31,4 +31,6 @@ end
|
||||
|
||||
function event()
|
||||
execute_point_selects()
|
||||
|
||||
check_reconnect()
|
||||
end
|
||||
|
||||
@ -54,4 +54,6 @@ function event()
|
||||
if not sysbench.opt.skip_trx then
|
||||
commit()
|
||||
end
|
||||
|
||||
check_reconnect()
|
||||
end
|
||||
|
||||
@ -62,4 +62,6 @@ function event()
|
||||
if not sysbench.opt.skip_trx then
|
||||
commit()
|
||||
end
|
||||
|
||||
check_reconnect()
|
||||
end
|
||||
|
||||
@ -27,4 +27,5 @@ end
|
||||
|
||||
function event()
|
||||
execute_index_updates(con)
|
||||
check_reconnect()
|
||||
end
|
||||
|
||||
@ -27,4 +27,6 @@ end
|
||||
|
||||
function event()
|
||||
execute_non_index_updates()
|
||||
|
||||
check_reconnect()
|
||||
end
|
||||
|
||||
@ -44,4 +44,6 @@ function event()
|
||||
if not sysbench.opt.skip_trx then
|
||||
commit()
|
||||
end
|
||||
|
||||
check_reconnect()
|
||||
end
|
||||
|
||||
@ -69,4 +69,6 @@ function event()
|
||||
end
|
||||
|
||||
stmt:execute()
|
||||
|
||||
check_reconnect()
|
||||
end
|
||||
|
||||
@ -74,4 +74,6 @@ function event()
|
||||
end
|
||||
|
||||
stmt:execute()
|
||||
|
||||
check_reconnect()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user