Tidy up protecting against corrupt Keys
this was previously not na issue as leveled_codec:segment_hash/1 would handle anyhting that could be hashed. This now has to be a tuple, and one with a first element - so corrupted tuples are failing. Add a guard chekcing for a corrupted tuple, but we only need this when doing journal compaction. Change user_defined keys to be `retain` as a tag strategy
This commit is contained in:
parent
cee5a60ceb
commit
714e128df8
4 changed files with 51 additions and 26 deletions
|
@ -357,7 +357,8 @@ 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,
|
||||
CheckerFilterFun =
|
||||
wrap_checkfilterfun(fun leveled_penciller:pcl_checksequencenumber/3),
|
||||
gen_server:call(Pid,
|
||||
{compact,
|
||||
Bookie,
|
||||
|
@ -1185,6 +1186,20 @@ initiate_penciller_snapshot(Bookie) ->
|
|||
MaxSQN = leveled_penciller:pcl_getstartupsequencenumber(LedgerSnap),
|
||||
{LedgerSnap, MaxSQN}.
|
||||
|
||||
|
||||
-spec wrap_checkfilterfun(fun()) -> fun().
|
||||
%% @doc
|
||||
%% Make a check of the validity of the key being passed into the CheckFilterFun
|
||||
wrap_checkfilterfun(CheckFilterFun) ->
|
||||
fun(Pcl, LK, SQN) ->
|
||||
case leveled_codec:isvalid_ledgerkey(LK) of
|
||||
true ->
|
||||
CheckFilterFun(Pcl, LK, SQN);
|
||||
false ->
|
||||
false
|
||||
end
|
||||
end.
|
||||
|
||||
%%%============================================================================
|
||||
%%% Test
|
||||
%%%============================================================================
|
||||
|
@ -1438,6 +1453,16 @@ empty_manifest_test() ->
|
|||
ink_close(Ink2),
|
||||
clean_testdir(RootPath).
|
||||
|
||||
|
||||
wrapper_test() ->
|
||||
KeyNotTuple = [?STD_TAG, <<"B">>, <<"K">>, null],
|
||||
TagNotAtom = {"tag", <<"B">>, <<"K">>, null},
|
||||
CheckFilterFun = fun(_Pcl, _LK, _SQN) -> true end,
|
||||
WrappedFun = wrap_checkfilterfun(CheckFilterFun),
|
||||
?assertMatch(false, WrappedFun(null, KeyNotTuple, 1)),
|
||||
?assertMatch(false, WrappedFun(null, TagNotAtom, 1)).
|
||||
|
||||
|
||||
coverage_cheat_test() ->
|
||||
{noreply, _State0} = handle_info(timeout, #state{}),
|
||||
{ok, _State1} = code_change(null, #state{}, null).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue