Skip to content

Commit

Permalink
Zero sockets_used/sockets_limit stats
Browse files Browse the repository at this point in the history
They are no longer used.

This removes a couple file_handle_cache:info/1 calls.
  • Loading branch information
lhoguin committed Jun 14, 2024
1 parent 07ff2f0 commit ed0bb18
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 47 deletions.
42 changes: 0 additions & 42 deletions deps/rabbit/test/unit_file_handle_cache_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ groups() ->
[
{non_parallel_tests, [], [
file_handle_cache, %% Change FHC limit.
file_handle_cache_reserve,
file_handle_cache_reserve_release,
file_handle_cache_reserve_monitor,
file_handle_cache_reserve_open_file_above_limit
Expand Down Expand Up @@ -134,47 +133,6 @@ file_handle_cache1(_Config) ->
ok = file_handle_cache:set_limit(Limit),
passed.

file_handle_cache_reserve(Config) ->
passed = rabbit_ct_broker_helpers:rpc(Config, 0,
?MODULE, file_handle_cache_reserve1, [Config]).

file_handle_cache_reserve1(_Config) ->
Limit = file_handle_cache:get_limit(),
ok = file_handle_cache:set_limit(5),
%% Reserves are always accepted, even if above the limit
%% These are for special processes such as quorum queues
ok = file_handle_cache:set_reservation(7),

Self = self(),
spawn(fun () -> ok = file_handle_cache:obtain(),
Self ! obtained
end),

Props = file_handle_cache:info([files_reserved, sockets_used]),
?assertEqual(7, proplists:get_value(files_reserved, Props)),
?assertEqual(0, proplists:get_value(sockets_used, Props)),

%% The obtain should still be blocked, as there are no file handles
%% available
receive
obtained ->
throw(error_file_obtained)
after 1000 ->
%% Let's release 5 file handles, that should leave
%% enough free for the `obtain` to go through
file_handle_cache:set_reservation(2),
Props0 = file_handle_cache:info([files_reserved, sockets_used]),
?assertEqual(2, proplists:get_value(files_reserved, Props0)),
?assertEqual(1, proplists:get_value(sockets_used, Props0)),
receive
obtained ->
ok = file_handle_cache:set_limit(Limit),
passed
after 5000 ->
throw(error_file_not_released)
end
end.

file_handle_cache_reserve_release(Config) ->
passed = rabbit_ct_broker_helpers:rpc(Config, 0,
?MODULE, file_handle_cache_reserve_release1, [Config]).
Expand Down
5 changes: 2 additions & 3 deletions deps/rabbit_common/src/file_handle_cache.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1087,9 +1087,8 @@ infos(Items, State) -> [{Item, i(Item, State)} || Item <- Items].

i(total_limit, #fhc_state{limit = Limit}) -> Limit;
i(total_used, State) -> used(State);
i(sockets_limit, #fhc_state{obtain_limit = Limit}) -> Limit;
i(sockets_used, #fhc_state{obtain_count_socket = Count,
reserve_count_socket = RCount}) -> Count + RCount;
i(sockets_limit, _) -> 0;
i(sockets_used, _) -> 0;
i(files_reserved, #fhc_state{reserve_count_file = RCount}) -> RCount;
i(Item, _) -> throw({bad_argument, Item}).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,11 @@ i(fd_used, State) ->
get_used_fd(State);
i(fd_total, #state{fd_total = FdTotal}=State) ->
{State, FdTotal};
%% sockets_used and sockets_total are unused since RabbitMQ 4.0.
i(sockets_used, State) ->
{State, proplists:get_value(sockets_used, file_handle_cache:info([sockets_used]))};
{State, 0};
i(sockets_total, State) ->
{State, proplists:get_value(sockets_limit, file_handle_cache:info([sockets_limit]))};
{State, 0};
i(os_pid, State) ->
{State, rabbit_data_coercion:to_utf8_binary(os:getpid())};
i(mem_used, State) ->
Expand Down

0 comments on commit ed0bb18

Please sign in to comment.