Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kjnilsson committed Nov 28, 2024
1 parent be458a7 commit 1c1d4c3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/ra_log_segment_writer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,7 @@ send_segments(System, ServerUId, TidRanges, SegRefs) ->
[ServerUId, "No Pid"]),
%% delete from the memtable on the non-running server's behalf
[begin
%% this looks a bit weird but
%% we dont need full init to run a delete
_ = ra_mt:delete({range, Tid, Range})
_ = catch ra_mt:delete({range, Tid, Range})
end || {Tid, Range} <- TidRanges],
ok;
Pid ->
Expand Down
28 changes: 28 additions & 0 deletions test/ra_log_2_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ all_tests() ->
handle_overwrite,
handle_overwrite_append,
receive_segment,
delete_during_segment_flush,
read_one,
take_after_overwrite_and_init,
validate_sequential_fold,
Expand Down Expand Up @@ -212,6 +213,33 @@ receive_segment(Config) ->
ra_log:close(FinalLog),
ok.

delete_during_segment_flush(Config) ->
Log0 = ra_log_init(Config),
Data = crypto:strong_rand_bytes(4000),
% write a few entries
Entries = [{I, 1, Data} || I <- lists:seq(1, 100000)],

{PreWritten, _} = ra_log:last_written(Log0),
Log1 = lists:foldl(fun(E, Acc0) ->
ra_log:append(E, Acc0)
end, Log0, Entries),
Log2 = deliver_log_events_cond(
Log1, fun (L) ->
{PostWritten, _} = ra_log:last_written(L),
PostWritten >= (PreWritten + 10000)
end, 100),
_Ref = monitor(process, ra_log_segment_writer),
% force wal roll over
ok = ra_log_wal:force_roll_over(ra_log_wal),

ra_log:delete_everything(Log2),


timer:sleep(1000),
flush(),

ok.

read_one(Config) ->
ra_counters:new(?FUNCTION_NAME, ?RA_COUNTER_FIELDS),
Log0 = ra_log_init(Config, #{counter => ra_counters:fetch(?FUNCTION_NAME)}),
Expand Down

0 comments on commit 1c1d4c3

Please sign in to comment.