Release penciller snapshot after journal compaction
As otherwise memory consumption beocmes an issue, as they will take an hour to timeout naturally.
This commit is contained in:
parent
5c5fa8ee8d
commit
c664176247
2 changed files with 16 additions and 6 deletions
|
@ -80,7 +80,7 @@
|
|||
handle_info/2,
|
||||
terminate/2,
|
||||
clerk_new/1,
|
||||
clerk_compact/6,
|
||||
clerk_compact/7,
|
||||
clerk_hashtablecalc/3,
|
||||
clerk_stop/1,
|
||||
code_change/3]).
|
||||
|
@ -124,14 +124,15 @@
|
|||
clerk_new(InkerClerkOpts) ->
|
||||
gen_server:start(?MODULE, [InkerClerkOpts], []).
|
||||
|
||||
clerk_compact(Pid, Checker, InitiateFun, FilterFun, Inker, Timeout) ->
|
||||
clerk_compact(Pid, Checker, InitiateFun, CloseFun, FilterFun, Inker, TimeO) ->
|
||||
gen_server:cast(Pid,
|
||||
{compact,
|
||||
Checker,
|
||||
InitiateFun,
|
||||
CloseFun,
|
||||
FilterFun,
|
||||
Inker,
|
||||
Timeout}).
|
||||
TimeO}).
|
||||
|
||||
clerk_hashtablecalc(HashTree, StartPos, CDBpid) ->
|
||||
{ok, Clerk} = gen_server:start(?MODULE, [#iclerk_options{}], []),
|
||||
|
@ -171,7 +172,7 @@ init([IClerkOpts]) ->
|
|||
handle_call(_Msg, _From, State) ->
|
||||
{reply, not_supported, State}.
|
||||
|
||||
handle_cast({compact, Checker, InitiateFun, FilterFun, Inker, _Timeout},
|
||||
handle_cast({compact, Checker, InitiateFun, CloseFun, FilterFun, Inker, _TO},
|
||||
State) ->
|
||||
% Empty the waste folder
|
||||
clear_waste(State),
|
||||
|
@ -207,11 +208,13 @@ handle_cast({compact, Checker, InitiateFun, FilterFun, Inker, _Timeout},
|
|||
update_inker(Inker,
|
||||
ManifestSlice,
|
||||
FilesToDelete),
|
||||
ok = CloseFun(FilterServer),
|
||||
{noreply, State}
|
||||
end;
|
||||
Score ->
|
||||
leveled_log:log("IC003", [Score]),
|
||||
ok = leveled_inker:ink_compactioncomplete(Inker),
|
||||
ok = CloseFun(FilterServer),
|
||||
{noreply, State}
|
||||
end;
|
||||
handle_cast({hashtable_calc, HashTree, StartPos, CDBpid}, State) ->
|
||||
|
|
|
@ -178,22 +178,25 @@ ink_loadpcl(Pid, MinSQN, FilterFun, Penciller) ->
|
|||
|
||||
ink_compactjournal(Pid, Bookie, Timeout) ->
|
||||
CheckerInitiateFun = fun initiate_penciller_snapshot/1,
|
||||
CheckerCloseFun = fun leveled_penciller:pcl_close/1,
|
||||
CheckerFilterFun = fun leveled_penciller:pcl_checksequencenumber/3,
|
||||
gen_server:call(Pid,
|
||||
{compact,
|
||||
Bookie,
|
||||
CheckerInitiateFun,
|
||||
CheckerCloseFun,
|
||||
CheckerFilterFun,
|
||||
Timeout},
|
||||
infinity).
|
||||
|
||||
%% Allows the Checker to be overriden in test, use something other than a
|
||||
%% penciller
|
||||
ink_compactjournal(Pid, Checker, InitiateFun, FilterFun, Timeout) ->
|
||||
ink_compactjournal(Pid, Checker, InitiateFun, CloseFun, FilterFun, Timeout) ->
|
||||
gen_server:call(Pid,
|
||||
{compact,
|
||||
Checker,
|
||||
InitiateFun,
|
||||
CloseFun,
|
||||
FilterFun,
|
||||
Timeout},
|
||||
infinity).
|
||||
|
@ -308,12 +311,14 @@ handle_call(print_manifest, _From, State) ->
|
|||
handle_call({compact,
|
||||
Checker,
|
||||
InitiateFun,
|
||||
CloseFun,
|
||||
FilterFun,
|
||||
Timeout},
|
||||
_From, State) ->
|
||||
leveled_iclerk:clerk_compact(State#state.clerk,
|
||||
Checker,
|
||||
InitiateFun,
|
||||
CloseFun,
|
||||
FilterFun,
|
||||
self(),
|
||||
Timeout),
|
||||
|
@ -720,7 +725,6 @@ initiate_penciller_snapshot(Bookie) ->
|
|||
MaxSQN = leveled_penciller:pcl_getstartupsequencenumber(LedgerSnap),
|
||||
{LedgerSnap, MaxSQN}.
|
||||
|
||||
|
||||
%%%============================================================================
|
||||
%%% Test
|
||||
%%%============================================================================
|
||||
|
@ -878,6 +882,7 @@ compact_journal_test() ->
|
|||
ok = ink_compactjournal(Ink1,
|
||||
Checker,
|
||||
fun(X) -> {X, 55} end,
|
||||
fun(_F) -> ok end,
|
||||
fun(L, K, SQN) -> lists:member({SQN, K}, L) end,
|
||||
5000),
|
||||
timer:sleep(1000),
|
||||
|
@ -887,6 +892,7 @@ compact_journal_test() ->
|
|||
ok = ink_compactjournal(Ink1,
|
||||
Checker2,
|
||||
fun(X) -> {X, 55} end,
|
||||
fun(_F) -> ok end,
|
||||
fun(L, K, SQN) -> lists:member({SQN, K}, L) end,
|
||||
5000),
|
||||
timer:sleep(1000),
|
||||
|
@ -918,6 +924,7 @@ empty_manifest_test() ->
|
|||
ok = ink_compactjournal(Ink1,
|
||||
[],
|
||||
fun(X) -> {X, 55} end,
|
||||
fun(_F) -> ok end,
|
||||
CheckFun,
|
||||
5000),
|
||||
timer:sleep(1000),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue