Fix issue with use of ets:next
ets:next is not StartInclusive - so we shouldn't use ets:next when querying the ledger cache, until it has been confirmed thta a matching key to the StartKey is not present. This reoslves the intermittently failing unit test which highlighted this (and also makes that intermittent failure a permanent failure by expanding the test cases it covers).
This commit is contained in:
parent
12dae9209a
commit
941d4d2577
1 changed files with 50 additions and 28 deletions
|
@ -1125,7 +1125,14 @@ readycache_forsnapshot(LedgerCache, Query) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
scan_table(Table, StartKey, EndKey) ->
|
scan_table(Table, StartKey, EndKey) ->
|
||||||
scan_table(Table, StartKey, EndKey, [], infinity, 0).
|
case ets:lookup(Table, StartKey) of
|
||||||
|
[] ->
|
||||||
|
scan_table(Table, StartKey, EndKey, [], infinity, 0);
|
||||||
|
[{StartKey, StartVal}] ->
|
||||||
|
SQN = leveled_codec:strip_to_seqonly({StartKey, StartVal}),
|
||||||
|
scan_table(Table, StartKey, EndKey,
|
||||||
|
[{StartKey, StartVal}], SQN, SQN)
|
||||||
|
end.
|
||||||
|
|
||||||
scan_table(Table, StartKey, EndKey, Acc, MinSQN, MaxSQN) ->
|
scan_table(Table, StartKey, EndKey, Acc, MinSQN, MaxSQN) ->
|
||||||
case ets:next(Table, StartKey) of
|
case ets:next(Table, StartKey) of
|
||||||
|
@ -1884,12 +1891,18 @@ foldobjects_vs_foldheads_bybucket_testto() ->
|
||||||
?assertMatch(true,
|
?assertMatch(true,
|
||||||
lists:usort(KeyHashList2B) == lists:usort(KeyHashList2D)),
|
lists:usort(KeyHashList2B) == lists:usort(KeyHashList2D)),
|
||||||
|
|
||||||
|
|
||||||
|
CheckSplitQueryFun =
|
||||||
|
fun(SplitInt) ->
|
||||||
|
io:format("Testing SplitInt ~w~n", [SplitInt]),
|
||||||
|
SplitIntEnd = "Key" ++ integer_to_list(SplitInt) ++ "|",
|
||||||
|
SplitIntStart = "Key" ++ integer_to_list(SplitInt + 1),
|
||||||
{async, HTFolder2E} =
|
{async, HTFolder2E} =
|
||||||
book_returnfolder(Bookie1,
|
book_returnfolder(Bookie1,
|
||||||
{foldheads_bybucket,
|
{foldheads_bybucket,
|
||||||
?STD_TAG,
|
?STD_TAG,
|
||||||
"BucketB",
|
"BucketB",
|
||||||
{"Key", "Key4|"},
|
{"Key", SplitIntEnd},
|
||||||
FoldHeadsFun,
|
FoldHeadsFun,
|
||||||
true, false, false}),
|
true, false, false}),
|
||||||
KeyHashList2E = HTFolder2E(),
|
KeyHashList2E = HTFolder2E(),
|
||||||
|
@ -1898,7 +1911,7 @@ foldobjects_vs_foldheads_bybucket_testto() ->
|
||||||
{foldheads_bybucket,
|
{foldheads_bybucket,
|
||||||
?STD_TAG,
|
?STD_TAG,
|
||||||
"BucketB",
|
"BucketB",
|
||||||
{"Key5", "Key|"},
|
{SplitIntStart, "Key|"},
|
||||||
FoldHeadsFun,
|
FoldHeadsFun,
|
||||||
true, false, false}),
|
true, false, false}),
|
||||||
KeyHashList2F = HTFolder2F(),
|
KeyHashList2F = HTFolder2F(),
|
||||||
|
@ -1909,9 +1922,18 @@ foldobjects_vs_foldheads_bybucket_testto() ->
|
||||||
[length(KeyHashList2B),
|
[length(KeyHashList2B),
|
||||||
length(KeyHashList2E),
|
length(KeyHashList2E),
|
||||||
length(KeyHashList2F)]),
|
length(KeyHashList2F)]),
|
||||||
?assertMatch(true,
|
CompareL = lists:usort(KeyHashList2E ++ KeyHashList2F),
|
||||||
lists:usort(KeyHashList2B) ==
|
SubtractL = lists:subtract(KeyHashList2B, CompareL),
|
||||||
lists:usort(KeyHashList2E ++ KeyHashList2F)),
|
case length(SubtractL) of
|
||||||
|
0 ->
|
||||||
|
io:format("Test looks like passing~n");
|
||||||
|
_L ->
|
||||||
|
io:format("Failure on SplitInt ~w~n", [SplitInt])
|
||||||
|
end,
|
||||||
|
?assertMatch(true, lists:usort(KeyHashList2B) == CompareL)
|
||||||
|
end,
|
||||||
|
|
||||||
|
lists:foreach(CheckSplitQueryFun, [1, 4, 8, 300, 100, 400]),
|
||||||
|
|
||||||
ok = book_close(Bookie1),
|
ok = book_close(Bookie1),
|
||||||
reset_filestructure().
|
reset_filestructure().
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue