Prevent double work ongoing
This was the cause of the pclerk crash. The concurrent work would lead to the attempt to re-fetch the prompted deletions after they had been deleted.
This commit is contained in:
parent
b12cd13bba
commit
793977b76c
1 changed files with 16 additions and 5 deletions
|
@ -511,10 +511,19 @@ handle_cast({levelzero_complete, FN, StartKey, EndKey}, State) ->
|
||||||
manifest=UpdMan,
|
manifest=UpdMan,
|
||||||
persisted_sqn=State#state.ledger_sqn}};
|
persisted_sqn=State#state.ledger_sqn}};
|
||||||
handle_cast(work_for_clerk, State) ->
|
handle_cast(work_for_clerk, State) ->
|
||||||
case State#state.levelzero_pending of
|
case {State#state.levelzero_pending, State#state.work_ongoing} of
|
||||||
true ->
|
{false, false} ->
|
||||||
{noreply, State};
|
% TODO - as part of supervision tree and retry work:
|
||||||
false ->
|
% Need to check for work_ongoing as well as levelzero_pending as
|
||||||
|
% there may be a race that could lead to the clerk doing the same
|
||||||
|
% thing twice.
|
||||||
|
%
|
||||||
|
% This has implications though if we auto-restart the pclerk in the
|
||||||
|
% future, without altering this state - it may never be able to
|
||||||
|
% request work due to ongoing work that crashed the previous clerk
|
||||||
|
%
|
||||||
|
% Perhaps the pclerk should not be restarted because of this, and
|
||||||
|
% the failure should ripple up
|
||||||
{WL, WC} = leveled_pmanifest:check_for_work(State#state.manifest,
|
{WL, WC} = leveled_pmanifest:check_for_work(State#state.manifest,
|
||||||
?LEVEL_SCALEFACTOR),
|
?LEVEL_SCALEFACTOR),
|
||||||
case WC of
|
case WC of
|
||||||
|
@ -534,7 +543,9 @@ handle_cast(work_for_clerk, State) ->
|
||||||
{TL, State#state.manifest}),
|
{TL, State#state.manifest}),
|
||||||
{noreply,
|
{noreply,
|
||||||
State#state{work_backlog=false, work_ongoing=true}}
|
State#state{work_backlog=false, work_ongoing=true}}
|
||||||
end
|
end;
|
||||||
|
_ ->
|
||||||
|
{noreply, State}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue