8000 Merge pull request #1898 from rabbitmq/defend-conn-created-tracking · rabbitmq/rabbitmq-server@161c716 · GitHub
[go: up one dir, main page]

Skip to content

Commit 161c716

Browse files
authored
Merge pull request #1898 from rabbitmq/defend-conn-created-tracking
Handle premature connection termination in connection tracking handler
2 parents d256c78 + 0dccf40 commit 161c716

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/rabbit_connection_tracking_handler.erl

Lines changed: 19 additions & 7 deletions
< 8000 tr class="diff-line-row"> 773F
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,25 @@ init([]) ->
5252
handle_event(#event{type = connection_created, props = Details}, State) ->
5353
ThisNode = node(),
5454
case pget(node, Details) of
55-
ThisNode ->
56-
rabbit_connection_tracking:register_connection(
57-
rabbit_connection_tracking:tracked_connection_from_connection_created(Details)
58-
);
59-
_OtherNode ->
60-
%% ignore
61-
ok
55+
ThisNode ->
56+
TConn = rabbit_connection_tracking:tracked_connection_from_connection_created(Details),
57+
ConnId = TConn#tracked_connection.id,
58+
try
59+
rabbit_connection_tracking:register_connection(TConn)
60+
catch
61+
error:{no_exists, _} ->
62+
Msg = "Could not register connection ~p for tracking, "
63+
"its table is not ready yet or the connection terminated prematurely",
64+
rabbit_log_connection:warning(Msg, [ConnId]),
65+
ok;
66+
error:Err ->
67+
Msg = "Could not register connection ~p for tracking: ~p",
68+
rabbit_log_connection:warning(Msg, [ConnId, Err]),
69+
ok
70+
end;
71+
_OtherNode ->
72+
%% ignore
73+
ok
6274
end,
6375
{ok, State};
6476
handle_event(#event{type = connection_closed, props = Details}, State) ->

0 commit comments

Comments
 (0)
0