Skip to content

Commit

Permalink
Mas i449 directpromptofdeletions (#450)
Browse files Browse the repository at this point in the history
* Move prompt of deletions to Inker

It is a series of casts, so no reason to offload this to the clerk.  Simplifies potential races in shutdown

* Rename

* Change cache sizes

In the hope of making test more consistent
  • Loading branch information
martinsumner authored Sep 4, 2024
1 parent af0f2bb commit 30ec921
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 22 deletions.
18 changes: 0 additions & 18 deletions src/leveled_iclerk.erl
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,15 @@
clerk_compact/6,
clerk_hashtablecalc/3,
clerk_trim/3,
clerk_promptdeletions/3,
clerk_stop/1,
clerk_loglevel/2,
clerk_addlogs/2,
clerk_removelogs/2]).

-export([schedule_compaction/3]).

-define(JOURNAL_FILEX, "cdb").
-define(PENDING_FILEX, "pnd").
-define(SAMPLE_SIZE, 192).
-define(BATCH_SIZE, 32).
-define(BATCHES_TO_CHECK, 8).
-define(CRC_SIZE, 4).
-define(DEFAULT_RELOAD_STRATEGY, leveled_codec:inker_reload_strategy([])).
-define(INTERVALS_PER_HOUR, 4).
Expand Down Expand Up @@ -188,12 +184,6 @@ clerk_compact(Pid, Checker, InitiateFun, CloseFun, FilterFun, Manifest) ->
clerk_trim(Pid, PersistedSQN, ManifestAsList) ->
gen_server:cast(Pid, {trim, PersistedSQN, ManifestAsList}).

-spec clerk_promptdeletions(pid(), pos_integer(), list()) -> ok.
%% @doc
%%
clerk_promptdeletions(Pid, ManifestSQN, DeletedFiles) ->
gen_server:cast(Pid, {prompt_deletions, ManifestSQN, DeletedFiles}).

-spec clerk_hashtablecalc(ets:tid(), integer(), pid()) -> ok.
%% @doc
%% Spawn a dedicated clerk for the process of calculating the binary view
Expand Down Expand Up @@ -419,14 +409,6 @@ handle_cast({trim, PersistedSQN, ManifestAsList}, State) ->
leveled_log:log(ic007, []),
ok = leveled_inker:ink_clerkcomplete(State#state.inker, [], FilesToDelete),
{noreply, State};
handle_cast({prompt_deletions, ManifestSQN, FilesToDelete}, State) ->
lists:foreach(fun({_SQN, _FN, J2D, _LK}) ->
leveled_cdb:cdb_deletepending(J2D,
ManifestSQN,
State#state.inker)
end,
FilesToDelete),
{noreply, State};
handle_cast({hashtable_calc, HashTree, StartPos, CDBpid}, State) ->
{IndexList, HashTreeBin} = leveled_cdb:hashtable_calc(HashTree, StartPos),
ok = leveled_cdb:cdb_returnhashtable(CDBpid, IndexList, HashTreeBin),
Expand Down
9 changes: 6 additions & 3 deletions src/leveled_inker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,12 @@ handle_cast({clerk_complete, ManifestSnippet, FilesToDelete}, State) ->
NewManifestSQN = State#state.manifest_sqn + 1,
leveled_imanifest:printer(Man1),
leveled_imanifest:writer(Man1, NewManifestSQN, State#state.root_path),
ok = leveled_iclerk:clerk_promptdeletions(State#state.clerk,
NewManifestSQN,
FilesToDelete),
lists:foreach(
fun({_SQN, _FN, J2D, _LK}) ->
leveled_cdb:cdb_deletepending(J2D, NewManifestSQN, self())
end,
FilesToDelete
),
{noreply, State#state{manifest=Man1,
manifest_sqn=NewManifestSQN,
pending_removals=FilesToDelete,
Expand Down
2 changes: 2 additions & 0 deletions test/end_to_end/basic_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ fetchput_snapshot(_Config) ->
RootPath = testutil:reset_filestructure(),
StartOpts1 = [{root_path, RootPath},
{max_journalsize, 30000000},
{cache_size, 2000},
{max_pencillercachesize, 16000},
{sync_strategy, none}],
{ok, Bookie1} = leveled_bookie:book_start(StartOpts1),
{TestObject, TestSpec} = testutil:generate_testobject(),
Expand Down
3 changes: 2 additions & 1 deletion test/property/leveled_statemeqc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
[{gen_fsm, send_event, 2}]}]).

-define(NUMTESTS, 1000).
-define(TEST_TIMEOUT, 300).
-define(QC_OUT(P),
eqc:on_output(fun(Str, Args) ->
io:format(user, Str, Args) end, P)).
Expand All @@ -42,7 +43,7 @@


eqc_test_() ->
Timeout = 50,
Timeout = ?TEST_TIMEOUT,
{timeout, max(2 * Timeout, Timeout + 10),
?_assertEqual(true, eqc:quickcheck(eqc:testing_time(Timeout, ?QC_OUT(prop_db()))))}.

Expand Down

0 comments on commit 30ec921

Please sign in to comment.