summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bakken <luke@bakken.io>2019-02-25 09:29:34 -0800
committerGitHub <noreply@github.com>2019-02-25 09:29:34 -0800
commit161c7162248ba594121fe61f65ca60e4e7136d46 (patch)
tree923d57b6cd649597de00e20aae147faa6b4588a5
parentd256c78560a9d73fb39d7c159eedc00768a35dc2 (diff)
parent0dccf404e4825da1a281bbe2ba21dc8bfa5b282f (diff)
downloadrabbitmq-server-git-161c7162248ba594121fe61f65ca60e4e7136d46.tar.gz
Merge pull request #1898 from rabbitmq/defend-conn-created-tracking
Handle premature connection termination in connection tracking handler
-rw-r--r--src/rabbit_connection_tracking_handler.erl26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/rabbit_connection_tracking_handler.erl b/src/rabbit_connection_tracking_handler.erl
index 19b6f8ab40..39e7748a75 100644
--- a/src/rabbit_connection_tracking_handler.erl
+++ b/src/rabbit_connection_tracking_handler.erl
@@ -52,13 +52,25 @@ init([]) ->
handle_event(#event{type = connection_created, props = Details}, State) ->
ThisNode = node(),
case pget(node, Details) of
- ThisNode ->
- rabbit_connection_tracking:register_connection(
- rabbit_connection_tracking:tracked_connection_from_connection_created(Details)
- );
- _OtherNode ->
- %% ignore
- ok
+ ThisNode ->
+ TConn = rabbit_connection_tracking:tracked_connection_from_connection_created(Details),
+ ConnId = TConn#tracked_connection.id,
+ try
+ rabbit_connection_tracking:register_connection(TConn)
+ catch
+ error:{no_exists, _} ->
+ Msg = "Could not register connection ~p for tracking, "
+ "its table is not ready yet or the connection terminated prematurely",
+ rabbit_log_connection:warning(Msg, [ConnId]),
+ ok;
+ error:Err ->
+ Msg = "Could not register connection ~p for tracking: ~p",
+ rabbit_log_connection:warning(Msg, [ConnId, Err]),
+ ok
+ end;
+ _OtherNode ->
+ %% ignore
+ ok
end,
{ok, State};
handle_event(#event{type = connection_closed, props = Details}, State) ->