Skip to content

Commit d8f44b9

Browse files
committed
Zero sockets_used/sockets_limit stats
They are no longer used. This removes a couple file_handle_cache:info/1 calls. We are not removing them from the HTTP API to avoid breaking things unintentionally.
1 parent cbaffc8 commit d8f44b9

File tree

3 files changed

+5
-47
lines changed

3 files changed

+5
-47
lines changed

deps/rabbit/test/unit_file_handle_cache_SUITE.erl

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ groups() ->
2525
[
2626
{non_parallel_tests, [], [
2727
file_handle_cache, %% Change FHC limit.
28-
file_handle_cache_reserve,
2928
file_handle_cache_reserve_release,
3029
file_handle_cache_reserve_monitor,
3130
file_handle_cache_reserve_open_file_above_limit
@@ -134,47 +133,6 @@ file_handle_cache1(_Config) ->
134133
ok = file_handle_cache:set_limit(Limit),
135134
passed.
136135

137-
file_handle_cache_reserve(Config) ->
138-
passed = rabbit_ct_broker_helpers:rpc(Config, 0,
139-
?MODULE, file_handle_cache_reserve1, [Config]).
140-
141-
file_handle_cache_reserve1(_Config) ->
142-
Limit = file_handle_cache:get_limit(),
143-
ok = file_handle_cache:set_limit(5),
144-
%% Reserves are always accepted, even if above the limit
145-
%% These are for special processes such as quorum queues
146-
ok = file_handle_cache:set_reservation(7),
147-
148-
Self = self(),
149-
spawn(fun () -> ok = file_handle_cache:obtain(),
150-
Self ! obtained
151-
end),
152-
153-
Props = file_handle_cache:info([files_reserved, sockets_used]),
154-
?assertEqual(7, proplists:get_value(files_reserved, Props)),
155-
?assertEqual(0, proplists:get_value(sockets_used, Props)),
156-
157-
%% The obtain should still be blocked, as there are no file handles
158-
%% available
159-
receive
160-
obtained ->
161-
throw(error_file_obtained)
162-
after 1000 ->
163-
%% Let's release 5 file handles, that should leave
164-
%% enough free for the `obtain` to go through
165-
file_handle_cache:set_reservation(2),
166-
Props0 = file_handle_cache:info([files_reserved, sockets_used]),
167-
?assertEqual(2, proplists:get_value(files_reserved, Props0)),
168-
?assertEqual(1, proplists:get_value(sockets_used, Props0)),
169-
receive
170-
obtained ->
171-
ok = file_handle_cache:set_limit(Limit),
172-
passed
173-
after 5000 ->
174-
throw(error_file_not_released)
175-
end
176-
end.
177-
178136
file_handle_cache_reserve_release(Config) ->
179137
passed = rabbit_ct_broker_helpers:rpc(Config, 0,
180138
?MODULE, file_handle_cache_reserve_release1, [Config]).

deps/rabbit_common/src/file_handle_cache.erl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,9 +1087,8 @@ infos(Items, State) -> [{Item, i(Item, State)} || Item <- Items].
10871087

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

deps/rabbitmq_management_agent/src/rabbit_mgmt_external_stats.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,11 @@ i(fd_used, State) ->
195195
get_used_fd(State);
196196
i(fd_total, #state{fd_total = FdTotal}=State) ->
197197
{State, FdTotal};
198+
%% sockets_used and sockets_total are unused since RabbitMQ 4.0.
198199
i(sockets_used, State) ->
199-
{State, proplists:get_value(sockets_used, file_handle_cache:info([sockets_used]))};
200+
{State, 0};
200201
i(sockets_total, State) ->
201-
{State, proplists:get_value(sockets_limit, file_handle_cache:info([sockets_limit]))};
202+
{State, 0};
202203
i(os_pid, State) ->
203204
{State, rabbit_data_coercion:to_utf8_binary(os:getpid())};
204205
i(mem_used, State) ->

0 commit comments

Comments
 (0)