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
[_Active|Manifest] = Manifest0,
{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 =
#scoring_state{filter_fun = FilterFun,
filter_server = FilterServer,