diff --git a/src/box/box.cc b/src/box/box.cc index d9c773e3a7cc403cada4a0f586cc6484be63a76a..6a5de775d3f8a6b6e43dbc7b85c9d3fd48bf9de0 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -243,6 +243,14 @@ box_set_readahead(int readahead) iobuf_set_readahead(readahead); } +extern "C" void +box_set_panic_on_wal_error(int /* yesno */) +{ + recovery_setup_panic(recovery, + cfg_geti("panic_on_snap_error"), + cfg_geti("panic_on_wal_error")); +} + /* }}} configuration bindings */ /** diff --git a/src/box/lua/load_cfg.lua b/src/box/lua/load_cfg.lua index 118e0c09cc80e549dae23a78bab101f323b6f15a..9937f9af616f9eedbab9b4f79f9654c926b2820c 100644 --- a/src/box/lua/load_cfg.lua +++ b/src/box/lua/load_cfg.lua @@ -12,6 +12,7 @@ void box_set_readahead(int readahead); void box_set_io_collect_interval(double interval); void box_set_too_long_threshold(double threshold); void box_set_snap_io_rate_limit(double limit); +void box_set_panic_on_wal_error(int); ]]) local log = require('log') @@ -128,7 +129,7 @@ local dynamic_cfg = { readahead = ffi.C.box_set_readahead, too_long_threshold = ffi.C.box_set_too_long_threshold, snap_io_rate_limit = ffi.C.box_set_snap_io_rate_limit, - + panic_on_wal_error = ffi.C.box_set_panic_on_wal_error, -- snapshot_daemon snapshot_period = box.internal.snapshot_daemon.set_snapshot_period, snapshot_count = box.internal.snapshot_daemon.set_snapshot_count, @@ -140,9 +141,10 @@ local dynamic_cfg_skip_at_load = { wal_mode = true, listen = true, replication_source = true, + wal_dir_rescan_delay = true, + panic_on_wal_error = true, } - local function prepare_cfg(cfg, default_cfg, template_cfg, modify_cfg, prefix) if cfg == nil then return {} diff --git a/src/box/replication.cc b/src/box/replication.cc index f6742554da8a6b60d6516f62fe1cac64d879cd74..8352df6535d01962433cc616c2d173c4bfa6ed93 100644 --- a/src/box/replication.cc +++ b/src/box/replication.cc @@ -52,6 +52,9 @@ Relay::Relay(int fd_arg, uint64_t sync_arg) { r = recovery_new(cfg_gets("snap_dir"), cfg_gets("wal_dir"), replication_send_row, this); + recovery_setup_panic(r, cfg_geti("panic_if_snap_error"), + cfg_geti("panic_if_wal_error")); + coio_init(&io); io.fd = fd_arg; sync = sync_arg; diff --git a/test/app/cfg.result b/test/app/cfg.result index b14c3974d48aa3417d1f5f4f74311664fbafa519..c7dec8e966298747cd6712267ddad0dc5856a3da 100644 --- a/test/app/cfg.result +++ b/test/app/cfg.result @@ -1,5 +1,5 @@ TAP version 13 -1..25 +1..29 ok - box is not started ok - invalid replication_source ok - invalid wal_mode @@ -15,6 +15,10 @@ ok - wal_mode change ok - wal_mode default value ok - wal_mode change ok - wal_mode default value +ok - panic_on_wal_mode default value +ok - panic_on_wal_mode new value +ok - wal_dir_rescan_delay default value +ok - wal_dir_rescan_delay new value ok - wal_mode fsync ok - wal_mode fsync -> fsync ok - wal_mode fsync -> write is not supported diff --git a/test/app/cfg.test.lua b/test/app/cfg.test.lua index 9bc072944dc6bcf58296556dead10d2bae62e1b2..7176f1652058912da8caa456137ebc43aa2f03bd 100755 --- a/test/app/cfg.test.lua +++ b/test/app/cfg.test.lua @@ -4,7 +4,7 @@ local tap = require('tap') local test = tap.test('cfg') local socket = require('socket') local fio = require('fio') -test:plan(25) +test:plan(29) -------------------------------------------------------------------------------- -- Invalid values @@ -68,6 +68,14 @@ test:is(box.cfg.wal_mode, "none", "wal_mode change") box.cfg{wal_mode = require('msgpack').NULL} test:is(box.cfg.wal_mode, "write", "wal_mode default value") +test:is(box.cfg.panic_on_wal_error, true, "panic_on_wal_mode default value") +box.cfg{panic_on_wal_error=false} +test:is(box.cfg.panic_on_wal_error, false, "panic_on_wal_mode new value") + +test:is(box.cfg.wal_dir_rescan_delay, 0.1, "wal_dir_rescan_delay default value") +box.cfg{wal_dir_rescan_delay=0.2} +test:is(box.cfg.wal_dir_rescan_delay, 0.2, "wal_dir_rescan_delay new value") + local tarantool_bin = arg[-1] local PANIC = 256 function run_script(code) diff --git a/test/box/cfg.result b/test/box/cfg.result index 8c6f7a77be508daa01c214c21156f56e16e95820..5ae566ae3322515f00133fb11edb94f5c77dc860 100644 --- a/test/box/cfg.result +++ b/test/box/cfg.result @@ -2,7 +2,7 @@ --# push filter 'admin: .*' to 'admin: <uri>' box.cfg.nosuchoption = 1 --- -- error: '[string "-- load_cfg.lua - internal file..."]:263: Attempt to modify a read-only +- error: '[string "-- load_cfg.lua - internal file..."]:265: Attempt to modify a read-only table' ... t = {} for k,v in pairs(box.cfg) do if type(v) ~= 'table' and type(v) ~= 'function' then table.insert(t, k..': '..tostring(v)) end end @@ -36,7 +36,7 @@ t -- must be read-only box.cfg() --- -- error: '[string "-- load_cfg.lua - internal file..."]:209: bad argument #1 to ''pairs'' +- error: '[string "-- load_cfg.lua - internal file..."]:211: bad argument #1 to ''pairs'' (table expected, got nil)' ... t = {} for k,v in pairs(box.cfg) do if type(v) ~= 'table' and type(v) ~= 'function' then table.insert(t, k..': '..tostring(v)) end end @@ -70,23 +70,23 @@ t -- check that cfg with unexpected parameter fails. box.cfg{sherlock = 'holmes'} --- -- error: '[string "-- load_cfg.lua - internal file..."]:165: Error: cfg parameter +- error: '[string "-- load_cfg.lua - internal file..."]:167: Error: cfg parameter ''sherlock'' is unexpected' ... -- check that cfg with unexpected type of parameter failes box.cfg{listen = {}} --- -- error: '[string "-- load_cfg.lua - internal file..."]:185: Error: cfg parameter +- error: '[string "-- load_cfg.lua - internal file..."]:187: Error: cfg parameter ''listen'' should be one of types: string, number' ... box.cfg{wal_dir = 0} --- -- error: '[string "-- load_cfg.lua - internal file..."]:179: Error: cfg parameter +- error: '[string "-- load_cfg.lua - internal file..."]:181: Error: cfg parameter ''wal_dir'' should be of type string' ... box.cfg{coredump = 'true'} --- -- error: '[string "-- load_cfg.lua - internal file..."]:179: Error: cfg parameter +- error: '[string "-- load_cfg.lua - internal file..."]:181: Error: cfg parameter ''coredump'' should be of type boolean' ... -------------------------------------------------------------------------------- @@ -94,17 +94,17 @@ box.cfg{coredump = 'true'} -------------------------------------------------------------------------------- box.cfg{slab_alloc_arena = "100500"} --- -- error: '[string "-- load_cfg.lua - internal file..."]:179: Error: cfg parameter +- error: '[string "-- load_cfg.lua - internal file..."]:181: Error: cfg parameter ''slab_alloc_arena'' should be of type number' ... box.cfg{sophia = "sophia"} --- -- error: '[string "-- load_cfg.lua - internal file..."]:173: Error: cfg parameter +- error: '[string "-- load_cfg.lua - internal file..."]:175: Error: cfg parameter ''sophia'' should be a table' ... box.cfg{sophia = {threads = "threads"}} --- -- error: '[string "-- load_cfg.lua - internal file..."]:179: Error: cfg parameter +- error: '[string "-- load_cfg.lua - internal file..."]:181: Error: cfg parameter ''sophia.threads'' should be of type number' ... --------------------------------------------------------------------------------