Handle corrupted Ledger Key when applying recovery strategy
Otherwise may blow up in journal_compaction_bustedjournal test
This commit is contained in:
parent
f3e962c43a
commit
c787e0cd78
1 changed files with 45 additions and 16 deletions
|
@ -198,31 +198,40 @@ compact_inkerkvc({_InkerKey, crc_wonky, false}, _Strategy) ->
|
||||||
compact_inkerkvc({{_SQN, ?INKT_TOMB, _LK}, _V, _CrcCheck}, _Strategy) ->
|
compact_inkerkvc({{_SQN, ?INKT_TOMB, _LK}, _V, _CrcCheck}, _Strategy) ->
|
||||||
skip;
|
skip;
|
||||||
compact_inkerkvc({{SQN, ?INKT_KEYD, LK}, V, CrcCheck}, Strategy) ->
|
compact_inkerkvc({{SQN, ?INKT_KEYD, LK}, V, CrcCheck}, Strategy) ->
|
||||||
{Tag, _, _, _} = LK,
|
case get_tagstrategy(LK, Strategy) of
|
||||||
{Tag, TagStrat} = lists:keyfind(Tag, 1, Strategy),
|
skip ->
|
||||||
case TagStrat of
|
skip;
|
||||||
retain ->
|
retain ->
|
||||||
{retain, {{SQN, ?INKT_KEYD, LK}, V, CrcCheck}};
|
{retain, {{SQN, ?INKT_KEYD, LK}, V, CrcCheck}};
|
||||||
TagStrat ->
|
TagStrat ->
|
||||||
{TagStrat, null}
|
{TagStrat, null}
|
||||||
end;
|
end;
|
||||||
compact_inkerkvc({{SQN, ?INKT_STND, LK}, V, CrcCheck}, Strategy) ->
|
compact_inkerkvc({{SQN, ?INKT_STND, LK}, V, CrcCheck}, Strategy) ->
|
||||||
{Tag, _, _, _} = LK,
|
case get_tagstrategy(LK, Strategy) of
|
||||||
case lists:keyfind(Tag, 1, Strategy) of
|
skip ->
|
||||||
{Tag, TagStrat} ->
|
skip;
|
||||||
case TagStrat of
|
|
||||||
retain ->
|
retain ->
|
||||||
{_V, KeyDeltas} = split_inkvalue(V),
|
{_V, KeyDeltas} = split_inkvalue(V),
|
||||||
{TagStrat, {{SQN, ?INKT_KEYD, LK}, {null, KeyDeltas}, CrcCheck}};
|
{retain, {{SQN, ?INKT_KEYD, LK}, {null, KeyDeltas}, CrcCheck}};
|
||||||
TagStrat ->
|
TagStrat ->
|
||||||
{TagStrat, null}
|
{TagStrat, null}
|
||||||
end;
|
end;
|
||||||
|
compact_inkerkvc(_KVC, _Strategy) ->
|
||||||
|
skip.
|
||||||
|
|
||||||
|
get_tagstrategy(LK, Strategy) ->
|
||||||
|
case LK of
|
||||||
|
{Tag, _, _, _} ->
|
||||||
|
case lists:keyfind(Tag, 1, Strategy) of
|
||||||
|
{Tag, TagStrat} ->
|
||||||
|
TagStrat;
|
||||||
false ->
|
false ->
|
||||||
leveled_log:log("IC012", [Tag, Strategy]),
|
leveled_log:log("IC012", [Tag, Strategy]),
|
||||||
skip
|
skip
|
||||||
end;
|
end;
|
||||||
compact_inkerkvc(_KVC, _Strategy) ->
|
_ ->
|
||||||
skip.
|
skip
|
||||||
|
end.
|
||||||
|
|
||||||
split_inkvalue(VBin) ->
|
split_inkvalue(VBin) ->
|
||||||
case is_binary(VBin) of
|
case is_binary(VBin) of
|
||||||
|
@ -429,6 +438,26 @@ endkey_passed_test() ->
|
||||||
?assertMatch(true, endkey_passed(TestKey, K2)).
|
?assertMatch(true, endkey_passed(TestKey, K2)).
|
||||||
|
|
||||||
|
|
||||||
|
corrupted_ledgerkey_test() ->
|
||||||
|
% When testing for compacted journal which has been corrupted, there may
|
||||||
|
% be a corruptes ledger key. Always skip these keys
|
||||||
|
% Key has become a 3-tuple not a 4-tuple
|
||||||
|
TagStrat1 = compact_inkerkvc({{1,
|
||||||
|
?INKT_STND,
|
||||||
|
{?STD_TAG, "B1", "K1andSK"}},
|
||||||
|
{},
|
||||||
|
true},
|
||||||
|
[{?STD_TAG, retain}]),
|
||||||
|
?assertMatch(skip, TagStrat1),
|
||||||
|
TagStrat2 = compact_inkerkvc({{1,
|
||||||
|
?INKT_KEYD,
|
||||||
|
{?STD_TAG, "B1", "K1andSK"}},
|
||||||
|
{},
|
||||||
|
true},
|
||||||
|
[{?STD_TAG, retain}]),
|
||||||
|
?assertMatch(skip, TagStrat2).
|
||||||
|
|
||||||
|
|
||||||
%% Test below proved that the overhead of performing hashes was trivial
|
%% Test below proved that the overhead of performing hashes was trivial
|
||||||
%% Maybe 5 microseconds per hash
|
%% Maybe 5 microseconds per hash
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue