Stop snapshots when the bookie stops
During EQC testing it was found that snapshots are still usable even if the bookie process crashes. This change has snapshots monitor the bookie and close when the bookie process dies.
This commit is contained in:
parent
a1269e5274
commit
ef9ac672e5
4 changed files with 72 additions and 2 deletions
|
@ -257,6 +257,7 @@
|
|||
is_snapshot = false :: boolean(),
|
||||
snapshot_fully_loaded = false :: boolean(),
|
||||
source_penciller :: pid() | undefined,
|
||||
bookie_monref :: reference() | undefined,
|
||||
levelzero_astree :: list() | undefined,
|
||||
|
||||
work_ongoing = false :: boolean(), % i.e. compaction work
|
||||
|
@ -583,6 +584,10 @@ init([PCLopts]) ->
|
|||
{undefined, _Snapshot=true, Query, BookiesMem} ->
|
||||
SrcPenciller = PCLopts#penciller_options.source_penciller,
|
||||
LongRunning = PCLopts#penciller_options.snapshot_longrunning,
|
||||
%% monitor the bookie, and close the snapshot when bookie
|
||||
%% exits
|
||||
BookieMonitor = erlang:monitor(process, PCLopts#penciller_options.bookies_pid),
|
||||
|
||||
{ok, State} = pcl_registersnapshot(SrcPenciller,
|
||||
self(),
|
||||
Query,
|
||||
|
@ -590,7 +595,8 @@ init([PCLopts]) ->
|
|||
LongRunning),
|
||||
leveled_log:log("P0001", [self()]),
|
||||
{ok, State#state{is_snapshot=true,
|
||||
source_penciller=SrcPenciller}};
|
||||
bookie_monref = BookieMonitor,
|
||||
source_penciller=SrcPenciller}};
|
||||
{_RootPath, _Snapshot=false, _Q, _BM} ->
|
||||
start_from_file(PCLopts)
|
||||
end.
|
||||
|
@ -943,6 +949,11 @@ handle_cast(work_for_clerk, State) ->
|
|||
end.
|
||||
|
||||
|
||||
%% handle the bookie stopping and stop this snapshot
|
||||
handle_info({'DOWN', BookieMonRef, process, _BookiePid, _Info},
|
||||
State=#state{bookie_monref = BookieMonRef}) ->
|
||||
ok = pcl_releasesnapshot(State#state.source_penciller, self()),
|
||||
{stop, normal, State};
|
||||
handle_info(_Info, State) ->
|
||||
{noreply, State}.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue