From 1d3fb18df722f72bc75993645b622b2464f0b8e8 Mon Sep 17 00:00:00 2001 From: martinsumner Date: Thu, 5 Jan 2017 18:43:55 +0000 Subject: [PATCH] Resolve snapshotting issue Need to make sure the extract from ets happens at the point the snapshot is taken. --- src/leveled_bookie.erl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/leveled_bookie.erl b/src/leveled_bookie.erl index 2532c28..7c6c189 100644 --- a/src/leveled_bookie.erl +++ b/src/leveled_bookie.erl @@ -457,8 +457,7 @@ code_change(_OldVsn, State, _Extra) -> %%%============================================================================ load_snapshot(LedgerSnapshot, LedgerCache) -> - Tab = LedgerCache#ledger_cache.mem, - CacheToLoad = {leveled_skiplist:from_orderedset(Tab), + CacheToLoad = {LedgerCache#ledger_cache.loader, LedgerCache#ledger_cache.min_sqn, LedgerCache#ledger_cache.max_sqn}, ok = leveled_penciller:pcl_loadsnapshot(LedgerSnapshot, CacheToLoad). @@ -704,18 +703,24 @@ snapshot_store(State, SnapType) -> PCLopts = #penciller_options{start_snapshot=true, source_penciller=State#state.penciller}, {ok, LedgerSnapshot} = leveled_penciller:pcl_start(PCLopts), + LedgerCache = readycache_forsnapshot(State#state.ledger_cache), case SnapType of store -> InkerOpts = #inker_options{start_snapshot=true, source_inker=State#state.inker}, {ok, JournalSnapshot} = leveled_inker:ink_start(InkerOpts), - {ok, {LedgerSnapshot, State#state.ledger_cache}, - JournalSnapshot}; + {ok, {LedgerSnapshot, LedgerCache}, JournalSnapshot}; ledger -> - {ok, {LedgerSnapshot, State#state.ledger_cache}, - null} + {ok, {LedgerSnapshot, LedgerCache}, null} 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) -> MaxJournalSize0 = get_opt(max_journalsize, Opts, 10000000000), JournalSizeJitter = MaxJournalSize0 div (100 div ?JOURNAL_SIZE_JITTER),