Resolve snapshotting issue

Need to make sure the extract from ets happens at the point the snapshot
is taken.
This commit is contained in:
martinsumner 2017-01-05 18:43:55 +00:00
parent 2c828b8eca
commit 1d3fb18df7

View file

@ -457,8 +457,7 @@ code_change(_OldVsn, State, _Extra) ->
%%%============================================================================ %%%============================================================================
load_snapshot(LedgerSnapshot, LedgerCache) -> load_snapshot(LedgerSnapshot, LedgerCache) ->
Tab = LedgerCache#ledger_cache.mem, CacheToLoad = {LedgerCache#ledger_cache.loader,
CacheToLoad = {leveled_skiplist:from_orderedset(Tab),
LedgerCache#ledger_cache.min_sqn, LedgerCache#ledger_cache.min_sqn,
LedgerCache#ledger_cache.max_sqn}, LedgerCache#ledger_cache.max_sqn},
ok = leveled_penciller:pcl_loadsnapshot(LedgerSnapshot, CacheToLoad). ok = leveled_penciller:pcl_loadsnapshot(LedgerSnapshot, CacheToLoad).
@ -704,18 +703,24 @@ snapshot_store(State, SnapType) ->
PCLopts = #penciller_options{start_snapshot=true, PCLopts = #penciller_options{start_snapshot=true,
source_penciller=State#state.penciller}, source_penciller=State#state.penciller},
{ok, LedgerSnapshot} = leveled_penciller:pcl_start(PCLopts), {ok, LedgerSnapshot} = leveled_penciller:pcl_start(PCLopts),
LedgerCache = readycache_forsnapshot(State#state.ledger_cache),
case SnapType of case SnapType of
store -> store ->
InkerOpts = #inker_options{start_snapshot=true, InkerOpts = #inker_options{start_snapshot=true,
source_inker=State#state.inker}, source_inker=State#state.inker},
{ok, JournalSnapshot} = leveled_inker:ink_start(InkerOpts), {ok, JournalSnapshot} = leveled_inker:ink_start(InkerOpts),
{ok, {LedgerSnapshot, State#state.ledger_cache}, {ok, {LedgerSnapshot, LedgerCache}, JournalSnapshot};
JournalSnapshot};
ledger -> ledger ->
{ok, {LedgerSnapshot, State#state.ledger_cache}, {ok, {LedgerSnapshot, LedgerCache}, null}
null}
end. end.
readycache_forsnapshot(LedgerCache) ->
% Need to convert the Ledger Cache away from using the ETS table
SkipList = leveled_skiplist:from_orderedset(LedgerCache#ledger_cache.mem),
MinSQN = LedgerCache#ledger_cache.min_sqn,
MaxSQN = LedgerCache#ledger_cache.max_sqn,
#ledger_cache{loader=SkipList, min_sqn=MinSQN, max_sqn=MaxSQN}.
set_options(Opts) -> set_options(Opts) ->
MaxJournalSize0 = get_opt(max_journalsize, Opts, 10000000000), MaxJournalSize0 = get_opt(max_journalsize, Opts, 10000000000),
JournalSizeJitter = MaxJournalSize0 div (100 div ?JOURNAL_SIZE_JITTER), JournalSizeJitter = MaxJournalSize0 div (100 div ?JOURNAL_SIZE_JITTER),