Don't score a rolling file

In giving an empty file a score of 0, a race condition was exposed.  A file might not be active, but might still be rolling - and then cna get scored as 0, and immediately compacted.  It will then be removed from the journal manifest.

Check each file is not rolling before making it a candidate for rolling.
This commit is contained in:
Martin Sumner 2020-03-16 21:41:47 +00:00
parent 5f7d261a87
commit 808a858d09
2 changed files with 6 additions and 2 deletions

View file

@ -307,7 +307,11 @@ handle_cast({compact, Checker, InitiateFun, CloseFun, FilterFun, Manifest0},
% Don't want to process a queued call waiting on an old manifest % Don't want to process a queued call waiting on an old manifest
[_Active|Manifest] = Manifest0, [_Active|Manifest] = Manifest0,
{FilterServer, MaxSQN} = InitiateFun(Checker), {FilterServer, MaxSQN} = InitiateFun(Checker),
ok = clerk_scorefilelist(self(), Manifest), NotRollingFun =
fun({_LowSQN, _FN, Pid, _LK}) ->
not leveled_cdb:cdb_isrolling(Pid)
end,
ok = clerk_scorefilelist(self(), lists:filter(NotRollingFun, Manifest)),
ScoringState = ScoringState =
#scoring_state{filter_fun = FilterFun, #scoring_state{filter_fun = FilterFun,
filter_server = FilterServer, filter_server = FilterServer,

View file

@ -905,7 +905,7 @@ handoff(_Config) ->
{sync_strategy, sync}], {sync_strategy, sync}],
{ok, Bookie1} = leveled_bookie:book_start(StartOpts1), {ok, Bookie1} = leveled_bookie:book_start(StartOpts1),
% Add some noe Riak objects in - which should be ignored in folds. % Add some none Riak objects in - which should be ignored in folds.
Hashes = testutil:stdload(Bookie1, 1000), Hashes = testutil:stdload(Bookie1, 1000),
% Generate 200K objects to be used within the test, and load them into % Generate 200K objects to be used within the test, and load them into
% the first store (outputting the generated objects as a list of lists) % the first store (outputting the generated objects as a list of lists)