Make snapshot timeout configurable

Also increase defaults.  In riak snapshots may be used to fold over all objects, and with delays at the receiving end, this could take significant time
This commit is contained in:
Martin Sumner 2018-12-14 11:23:04 +00:00
parent b344b7d827
commit 8bf36214e1
3 changed files with 46 additions and 19 deletions

View file

@ -78,7 +78,9 @@
source_penciller :: pid() | undefined, source_penciller :: pid() | undefined,
snapshot_longrunning = true :: boolean(), snapshot_longrunning = true :: boolean(),
compression_method = native :: lz4|native, compression_method = native :: lz4|native,
levelzero_cointoss = false :: boolean()}). levelzero_cointoss = false :: boolean(),
snaptimeout_short :: pos_integer() | undefined,
snaptimeout_long :: pos_integer() | undefined}).
-record(iclerk_options, -record(iclerk_options,
{inker :: pid() | undefined, {inker :: pid() | undefined,

View file

@ -104,7 +104,6 @@
-define(MIN_PCL_CACHE_SIZE, 400). -define(MIN_PCL_CACHE_SIZE, 400).
-define(MAX_PCL_CACHE_SIZE, 28000). -define(MAX_PCL_CACHE_SIZE, 28000).
% This is less than actual max - but COIN_SIDECOUNT % This is less than actual max - but COIN_SIDECOUNT
-define(SNAPSHOT_TIMEOUT, 300000).
-define(CACHE_SIZE_JITTER, 25). -define(CACHE_SIZE_JITTER, 25).
-define(JOURNAL_SIZE_JITTER, 20). -define(JOURNAL_SIZE_JITTER, 20).
-define(ABSOLUTEMAX_JOURNALSIZE, 4000000000). -define(ABSOLUTEMAX_JOURNALSIZE, 4000000000).
@ -118,6 +117,8 @@
-define(MAX_KEYCHECK_FREQUENCY, 100). -define(MAX_KEYCHECK_FREQUENCY, 100).
-define(MIN_KEYCHECK_FREQUENCY, 1). -define(MIN_KEYCHECK_FREQUENCY, 1).
-define(OPEN_LASTMOD_RANGE, {0, infinity}). -define(OPEN_LASTMOD_RANGE, {0, infinity}).
-define(PCL_SNAPTIMEOUT_SHORT, 900). % 15 minutes
-define(PCL_SNAPTIMEOUT_LONG, 43200). % 12 hours
-define(OPTION_DEFAULTS, -define(OPTION_DEFAULTS,
[{root_path, undefined}, [{root_path, undefined},
{snapshot_bookie, undefined}, {snapshot_bookie, undefined},
@ -135,7 +136,9 @@
{compression_point, ?COMPRESSION_POINT}, {compression_point, ?COMPRESSION_POINT},
{log_level, ?LOG_LEVEL}, {log_level, ?LOG_LEVEL},
{forced_logs, []}, {forced_logs, []},
{override_functions, []}]). {override_functions, []},
{pcl_snapshottimeout_short, ?PCL_SNAPTIMEOUT_SHORT},
{pcl_snapshottimeout_long, ?PCL_SNAPTIMEOUT_LONG}]).
-record(ledger_cache, {mem :: ets:tab(), -record(ledger_cache, {mem :: ets:tab(),
loader = leveled_tree:empty(?CACHE_TYPE) loader = leveled_tree:empty(?CACHE_TYPE)
@ -328,9 +331,19 @@
% "P0032", "SST12", "CDB19", "SST13", "I0019"]} % "P0032", "SST12", "CDB19", "SST13", "I0019"]}
% Will log all timing points even when log_level is not set to % Will log all timing points even when log_level is not set to
% support info % support info
{override_functions, list(leveled_head:appdefinable_function_tuple())} {override_functions, list(leveled_head:appdefinable_function_tuple())} |
% Provide a list of override functions that will be used for % Provide a list of override functions that will be used for
% user-defined tags % user-defined tags
{pcl_snapshottimeout_short, pos_integer()} |
% Time in seconds before a snapshot that has not been shutdown is
% assumed to have failed, and so requires to be torndown. The
% short timeout is applied to queries where long_running is set to
% false
{pcl_snapshottimeout_long, pos_integer()}
% Time in seconds before a snapshot that has not been shutdown is
% assumed to have failed, and so requires to be torndown. The
% short timeout is applied to queries where long_running is set to
% true
]. ].
@ -1564,6 +1577,9 @@ set_options(Opts) ->
SyncStrat = proplists:get_value(sync_strategy, Opts), SyncStrat = proplists:get_value(sync_strategy, Opts),
WRP = proplists:get_value(waste_retention_period, Opts), WRP = proplists:get_value(waste_retention_period, Opts),
SnapTimeoutShort = proplists:get_value(pcl_snapshottimeout_short, Opts),
SnapTimeoutLong = proplists:get_value(pcl_snapshottimeout_long, Opts),
AltStrategy = proplists:get_value(reload_strategy, Opts), AltStrategy = proplists:get_value(reload_strategy, Opts),
ReloadStrategy = leveled_codec:inker_reload_strategy(AltStrategy), ReloadStrategy = leveled_codec:inker_reload_strategy(AltStrategy),
@ -1613,6 +1629,8 @@ set_options(Opts) ->
#penciller_options{root_path = LedgerFP, #penciller_options{root_path = LedgerFP,
max_inmemory_tablesize = PCLL0CacheSize, max_inmemory_tablesize = PCLL0CacheSize,
levelzero_cointoss = true, levelzero_cointoss = true,
snaptimeout_short = SnapTimeoutShort,
snaptimeout_long = SnapTimeoutLong,
sst_options = sst_options =
#sst_options{press_method = CompressionMethod, #sst_options{press_method = CompressionMethod,
log_options=leveled_log:get_opts()}} log_options=leveled_log:get_opts()}}

View file

@ -236,8 +236,6 @@
-define(COIN_SIDECOUNT, 5). -define(COIN_SIDECOUNT, 5).
-define(SLOW_FETCH, 20000). -define(SLOW_FETCH, 20000).
-define(ITERATOR_SCANWIDTH, 4). -define(ITERATOR_SCANWIDTH, 4).
-define(SNAPSHOT_TIMEOUT_LONG, 3600).
-define(SNAPSHOT_TIMEOUT_SHORT, 600).
-define(TIMING_SAMPLECOUNTDOWN, 10000). -define(TIMING_SAMPLECOUNTDOWN, 10000).
-define(TIMING_SAMPLESIZE, 100). -define(TIMING_SAMPLESIZE, 100).
-define(OPEN_LASTMOD_RANGE, {0, infinity}). -define(OPEN_LASTMOD_RANGE, {0, infinity}).
@ -270,6 +268,9 @@
timings = no_timing :: pcl_timings(), timings = no_timing :: pcl_timings(),
timings_countdown = 0 :: integer(), timings_countdown = 0 :: integer(),
snaptimeout_short :: pos_integer()|undefined,
snaptimeout_long :: pos_integer()|undefined,
sst_options = #sst_options{} :: #sst_options{}}). sst_options = #sst_options{} :: #sst_options{}}).
-record(pcl_timings, -record(pcl_timings,
@ -633,7 +634,8 @@ init([LogOpts, PCLopts]) ->
LongRunning = PCLopts#penciller_options.snapshot_longrunning, LongRunning = PCLopts#penciller_options.snapshot_longrunning,
%% monitor the bookie, and close the snapshot when bookie %% monitor the bookie, and close the snapshot when bookie
%% exits %% exits
BookieMonitor = erlang:monitor(process, PCLopts#penciller_options.bookies_pid), BookieMonitor =
erlang:monitor(process, PCLopts#penciller_options.bookies_pid),
{ok, State} = pcl_registersnapshot(SrcPenciller, {ok, State} = pcl_registersnapshot(SrcPenciller,
self(), self(),
@ -793,24 +795,24 @@ handle_call({fetch_keys,
end; end;
handle_call(get_startup_sqn, _From, State) -> handle_call(get_startup_sqn, _From, State) ->
{reply, State#state.persisted_sqn, State}; {reply, State#state.persisted_sqn, State};
handle_call({register_snapshot, Snapshot, Query, BookiesMem, LR}, _From, State) -> handle_call({register_snapshot, Snapshot, Query, BookiesMem, LongRunning},
_From, State) ->
% Register and load a snapshot % Register and load a snapshot
% %
% For setup of the snapshot to be efficient should pass a query % For setup of the snapshot to be efficient should pass a query
% of (StartKey, EndKey) - this will avoid a fully copy of the penciller's % of (StartKey, EndKey) - this will avoid a fully copy of the penciller's
% memory being required to be trasnferred to the clone. However, this % memory being required to be trasnferred to the clone. However, this
% will not be a valid clone for fetch % will not be a valid clone for fetch
Timeout =
case LR of
true ->
?SNAPSHOT_TIMEOUT_LONG;
false ->
?SNAPSHOT_TIMEOUT_SHORT
end,
Manifest0 = leveled_pmanifest:add_snapshot(State#state.manifest, TimeO =
Snapshot, case LongRunning of
Timeout), true ->
State#state.snaptimeout_long;
false ->
State#state.snaptimeout_short
end,
Manifest0 =
leveled_pmanifest:add_snapshot(State#state.manifest, Snapshot, TimeO),
{BookieIncrTree, BookieIdx, MinSQN, MaxSQN} = BookiesMem, {BookieIncrTree, BookieIdx, MinSQN, MaxSQN} = BookiesMem,
LM1Cache = LM1Cache =
@ -1091,6 +1093,9 @@ start_from_file(PCLopts) ->
MaxTableSize = PCLopts#penciller_options.max_inmemory_tablesize, MaxTableSize = PCLopts#penciller_options.max_inmemory_tablesize,
OptsSST = PCLopts#penciller_options.sst_options, OptsSST = PCLopts#penciller_options.sst_options,
SnapTimeoutShort = PCLopts#penciller_options.snaptimeout_short,
SnapTimeoutLong = PCLopts#penciller_options.snaptimeout_long,
{ok, MergeClerk} = leveled_pclerk:clerk_new(self(), RootPath, OptsSST), {ok, MergeClerk} = leveled_pclerk:clerk_new(self(), RootPath, OptsSST),
CoinToss = PCLopts#penciller_options.levelzero_cointoss, CoinToss = PCLopts#penciller_options.levelzero_cointoss,
@ -1103,6 +1108,8 @@ start_from_file(PCLopts) ->
levelzero_maxcachesize = MaxTableSize, levelzero_maxcachesize = MaxTableSize,
levelzero_cointoss = CoinToss, levelzero_cointoss = CoinToss,
levelzero_index = leveled_pmem:new_index(), levelzero_index = leveled_pmem:new_index(),
snaptimeout_short = SnapTimeoutShort,
snaptimeout_long = SnapTimeoutLong,
sst_options = OptsSST}, sst_options = OptsSST},
%% Open manifest %% Open manifest