Skip to content

Commit 9b884bb

Browse files
Merge pull request #10375 from rabbitmq/catch-ets-exception-on-startup
Catch ETS exception when system is still starting
2 parents 5abeb75 + fb4f50d commit 9b884bb

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

deps/rabbitmq_stream/src/rabbit_stream.erl

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,19 @@ port() ->
8787
end.
8888

8989
port_from_listener() ->
90-
Listeners = rabbit_networking:node_listeners(node()),
91-
Port =
90+
try
91+
Listeners = rabbit_networking:node_listeners(node()),
9292
lists:foldl(fun (#listener{port = Port, protocol = stream}, _Acc) ->
9393
Port;
9494
(_, Acc) ->
9595
Acc
9696
end,
97-
undefined, Listeners),
98-
Port.
97+
undefined, Listeners)
98+
catch error:Reason ->
99+
%% can happen if a remote node calls and the current has not fully started yet
100+
rabbit_log:info("Error while retrieving stream plugin port: ~tp", [Reason]),
101+
{error, Reason}
102+
end.
99103

100104
tls_port() ->
101105
case application:get_env(rabbitmq_stream, advertised_tls_port,
@@ -108,16 +112,20 @@ tls_port() ->
108112
end.
109113

110114
tls_port_from_listener() ->
111-
Listeners = rabbit_networking:node_listeners(node()),
112-
Port =
115+
try
116+
Listeners = rabbit_networking:node_listeners(node()),
113117
lists:foldl(fun (#listener{port = Port, protocol = 'stream/ssl'},
114118
_Acc) ->
115119
Port;
116120
(_, Acc) ->
117121
Acc
118122
end,
119-
undefined, Listeners),
120-
Port.
123+
undefined, Listeners)
124+
catch error:Reason ->
125+
%% can happen if a remote node calls and the current has not fully started yet
126+
rabbit_log:info("Error while retrieving stream plugin port: ~tp", [Reason]),
127+
{error, Reason}
128+
end.
121129

122130
stop(_State) ->
123131
ok.

0 commit comments

Comments
 (0)