Skip to content

Commit

Permalink
Merge remote-tracking branch 'myself/dgud/kernel/disk_log_fix/ERIERL-…
Browse files Browse the repository at this point in the history
…870/OTP-19104' into maint

* myself/dgud/kernel/disk_log_fix/ERIERL-870/OTP-19104:
  Fix disk_log bug/typo
  • Loading branch information
dgud committed Jun 11, 2024
2 parents 948e3ad + 30da517 commit 98fa137
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
7 changes: 6 additions & 1 deletion lib/kernel/src/disk_log.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,12 @@ check_arg([], Res) ->
disk_log_1:read_size_file_version(Res#arg.file),
check_wrap_arg(Ret, OldSize, Version);
Res#arg.type =:= rotate ->
{ok, Res#arg{format = external}};
case Ret of
{ok, Patched} ->
{ok, Patched#arg{format = external}};
_ ->
Ret
end;
true ->
Ret
end;
Expand Down
24 changes: 17 additions & 7 deletions lib/kernel/test/disk_log_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

otp_6278/1, otp_10131/1, otp_16768/1, otp_16809/1]).

-export([head_fun/1, hf/0, lserv/1,
-export([head_fun/1, hf/0, hf_bin/0, lserv/1,
measure/0, init_m/1, xx/0]).

-export([init_per_testcase/2, end_per_testcase/2]).
Expand Down Expand Up @@ -835,8 +835,9 @@ rotate_1(Conf) when is_list(Conf) ->
ok = disk_log:close(Name),
del_rot_files(File, 4),
{ok, Name} = disk_log:open([{name,Name}, {type,rotate}, {size,{8000, 3}},
{format,external},
{file, File}]),
{format,external},
{head_func, {?MODULE, hf_bin, []}},
{file, File}]),
{B1, _T1} = x_mk_bytes(10000), % lost due to rotation
{B2, T2} = x_mk_bytes(5000), % file a.LOG.2.gx
{B3, T3} = x_mk_bytes(4000), % file a.LOG.1.gz
Expand All @@ -847,27 +848,32 @@ rotate_1(Conf) when is_list(Conf) ->
ok = disk_log:blog(Name, B2),
ok = disk_log:blog(Name, B3),
ok = disk_log:blog_terms(a, [B4, B5, B6]),
{ok, BinHeader} = hf_bin(),
Header = binary_to_list(BinHeader),
T20 = Header ++ T2,
case get_list(File ++ ".2.gz", Name, rotate) of
T2 ->
T20 ->
ok;
E2 ->
test_server_fail({bad_terms, E2, T2})
end,
T34 = T3 ++ T4,
T34 = Header ++ T3 ++ T4,
case get_list(File ++ ".1.gz", Name, rotate) of
T34 ->
ok;
E34 ->
test_server_fail({bad_terms, E34, T34})
end,
T50 = Header ++ T5,
case get_list(File ++ ".0.gz", Name, rotate) of
T5 ->
T50 ->
ok;
E5 ->
test_server_fail({bad_terms, E5, T5})
end,
T60 = Header ++ T6,
case get_list(File, Name) of
T6 ->
T60 ->
ok;
E6 ->
test_server_fail({bad_terms, E6, T6})
Expand Down Expand Up @@ -1409,6 +1415,10 @@ hf() ->
ets:update_counter(xxx, wrapc, 1),
{ok, [1,2,3]}.

hf_bin() ->
{ok, <<"1", "2", "3">>}.


%% Test head parameter.
plain_head(Conf) when is_list(Conf) ->
Dir = ?privdir(Conf),
Expand Down

0 comments on commit 98fa137

Please sign in to comment.