Mas d31 i413 (#415)
* Allow snapshots to be reused in queries Allow for a full bookie snapshot to be re-used for multiple queries, not just KV fetches. * Reduce log noise The internal dummy tag is expected so should not prompt a log on reload * Snapshot should have same status of active db wrt head_only and head_lookup * Allow logging to specified on snapshots * Shutdown snapshot bookie is primary goes down Inker and Penciller already will shut down based on `erlang:monitor/2` * Review feedback Formatting and code readability fixes
This commit is contained in:
parent
9e804924a8
commit
d544db5461
9 changed files with 289 additions and 183 deletions
|
@ -628,16 +628,16 @@ init([LogOpts, PCLopts]) ->
|
|||
%% exits
|
||||
BookieMonitor =
|
||||
erlang:monitor(process, PCLopts#penciller_options.bookies_pid),
|
||||
|
||||
{ok, State} = pcl_registersnapshot(SrcPenciller,
|
||||
self(),
|
||||
Query,
|
||||
BookiesMem,
|
||||
LongRunning),
|
||||
{ok, State} =
|
||||
pcl_registersnapshot(
|
||||
SrcPenciller, self(), Query, BookiesMem, LongRunning),
|
||||
leveled_log:log(p0001, [self()]),
|
||||
{ok, State#state{is_snapshot = true,
|
||||
bookie_monref = BookieMonitor,
|
||||
source_penciller = SrcPenciller}};
|
||||
{ok,
|
||||
State#state{
|
||||
is_snapshot = true,
|
||||
clerk = undefined,
|
||||
bookie_monref = BookieMonitor,
|
||||
source_penciller = SrcPenciller}};
|
||||
{_RootPath, _Snapshot=false, _Q, _BM} ->
|
||||
start_from_file(PCLopts)
|
||||
end.
|
||||
|
@ -1131,22 +1131,21 @@ handle_cast({fetch_levelzero, Slot, ReturnFun}, State) ->
|
|||
ReturnFun(lists:nth(Slot, State#state.levelzero_cache)),
|
||||
{noreply, State};
|
||||
handle_cast({log_level, LogLevel}, State) ->
|
||||
PC = State#state.clerk,
|
||||
ok = leveled_pclerk:clerk_loglevel(PC, LogLevel),
|
||||
ok = leveled_log:set_loglevel(LogLevel),
|
||||
update_clerk(
|
||||
State#state.clerk, fun leveled_pclerk:clerk_loglevel/2, LogLevel),
|
||||
SSTopts = State#state.sst_options,
|
||||
SSTopts0 = SSTopts#sst_options{log_options = leveled_log:get_opts()},
|
||||
{noreply, State#state{sst_options = SSTopts0}};
|
||||
handle_cast({add_logs, ForcedLogs}, State) ->
|
||||
PC = State#state.clerk,
|
||||
ok = leveled_pclerk:clerk_addlogs(PC, ForcedLogs),
|
||||
update_clerk(
|
||||
State#state.clerk, fun leveled_pclerk:clerk_addlogs/2, ForcedLogs),
|
||||
ok = leveled_log:add_forcedlogs(ForcedLogs),
|
||||
SSTopts = State#state.sst_options,
|
||||
SSTopts0 = SSTopts#sst_options{log_options = leveled_log:get_opts()},
|
||||
{noreply, State#state{sst_options = SSTopts0}};
|
||||
handle_cast({remove_logs, ForcedLogs}, State) ->
|
||||
PC = State#state.clerk,
|
||||
ok = leveled_pclerk:clerk_removelogs(PC, ForcedLogs),
|
||||
update_clerk(
|
||||
State#state.clerk, fun leveled_pclerk:clerk_removelogs/2, ForcedLogs),
|
||||
ok = leveled_log:remove_forcedlogs(ForcedLogs),
|
||||
SSTopts = State#state.sst_options,
|
||||
SSTopts0 = SSTopts#sst_options{log_options = leveled_log:get_opts()},
|
||||
|
@ -1224,6 +1223,12 @@ sst_filename(ManSQN, Level, Count) ->
|
|||
%%% Internal functions
|
||||
%%%============================================================================
|
||||
|
||||
-spec update_clerk(pid()|undefined, fun((pid(), term()) -> ok), term()) -> ok.
|
||||
update_clerk(undefined, _F, _T) ->
|
||||
ok;
|
||||
update_clerk(Clerk, F, T) when is_pid(Clerk) ->
|
||||
F(Clerk, T).
|
||||
|
||||
-spec start_from_file(penciller_options()) -> {ok, pcl_state()}.
|
||||
%% @doc
|
||||
%% Normal start of a penciller (i.e. not a snapshot), needs to read the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue