From 9736b075e28f79fab02efca3f4def1382074cbfb Mon Sep 17 00:00:00 2001 From: Dmitry Mescheryakov Date: Wed, 3 Feb 2016 14:28:50 +0300 Subject: [PATCH 01/17] Streamline checking for cluster partitioning Move check if we are current cluster master to earlier place in code. That way we will avoid unnecessary operations for master case. --- scripts/rabbitmq-server-ha.ocf | 44 ++++++++++++++++------------------ 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/scripts/rabbitmq-server-ha.ocf b/scripts/rabbitmq-server-ha.ocf index d1088bc42d9f..78629547f7d7 100755 --- a/scripts/rabbitmq-server-ha.ocf +++ b/scripts/rabbitmq-server-ha.ocf @@ -1399,34 +1399,32 @@ get_monitor() { if [ $rabbit_running -eq $OCF_SUCCESS ] then ocf_log info "${LH} rabbit app is running. checking if we are the part of healthy cluster" - rc_check=$OCF_ERR_GENERIC - nodelist=$(get_alive_pacemaker_nodes_but) - for node in $nodelist - do - status_master=1 - # Do not refetch the master status for *this* node as we know it already - if [ $rc -ne $OCF_RUNNING_MASTER ] ; then + + if [ $rc -eq $OCF_RUNNING_MASTER ] ; then + # The master is always running inside of its cluster + ocf_log info "${LH} rabbit app is running and is master of cluster" + rc_check=$OCF_SUCCESS + else + rc_check=$OCF_ERR_GENERIC + nodelist=$(get_alive_pacemaker_nodes_but) + for node in $nodelist + do ocf_log info "${LH} rabbit app is running. looking for master on $node" is_master $node status_master=$? ocf_log info "${LH} fetched master attribute for $node. attr value is ${status_master}" - else - # The master is always running inside of its cluster - ocf_log info "${LH} rabbit app is running and is member of healthy cluster" - rc_check=$OCF_SUCCESS - break - fi - if [ $status_master -eq 0 ] ; then - ocf_log info "${LH} rabbit app is running. master is $node" - if get_running_nodes | grep -q $(rabbit_node_name $node) - then - ocf_log info "${LH} rabbit app is running and is member of healthy cluster" - rc_check=$OCF_SUCCESS - break + if [ $status_master -eq 0 ] ; then + ocf_log info "${LH} rabbit app is running. master is $node" + if get_running_nodes | grep -q $(rabbit_node_name $node) + then + ocf_log info "${LH} rabbit app is running and is member of healthy cluster" + rc_check=$OCF_SUCCESS + break + fi fi - fi - done - [ $rc_check -eq $OCF_ERR_GENERIC ] && ocf_log err "${LH} rabbit node is running out of the cluster" + done + [ $rc_check -eq $OCF_ERR_GENERIC ] && ocf_log err "${LH} rabbit node is running out of the cluster" + fi else if [ "$OCF_CHECK_LEVEL" -gt 20 ]; then ocf_log info "${LH} rabbit app is not running. checking if there is a master" From e709a0a03f6c41a3d5e23bfa5c8e20484ea3222c Mon Sep 17 00:00:00 2001 From: Daniil Fedotov Date: Wed, 3 Feb 2016 14:47:27 +0000 Subject: [PATCH 02/17] Lager integration for windows service script --- scripts/rabbitmq-service.bat | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/rabbitmq-service.bat b/scripts/rabbitmq-service.bat index 59425540e672..404d167d0388 100644 --- a/scripts/rabbitmq-service.bat +++ b/scripts/rabbitmq-service.bat @@ -144,6 +144,12 @@ if not "!RABBITMQ_NODE_IP_ADDRESS!"=="" ( ) ) +if "!RABBITMQ_LOGS!" == "-" ( + set RABBIT_LAGER_HANDLER=tty +) else ( + set RABBIT_LAGER_HANDLER=\""!RABBITMQ_LOGS:\=/!"\" +) + set RABBITMQ_START_RABBIT= if "!RABBITMQ_NODE_ONLY!"=="" ( set RABBITMQ_START_RABBIT=-s "!RABBITMQ_BOOT_MODULE!" boot @@ -167,8 +173,8 @@ set ERLANG_SERVICE_ARGUMENTS= ^ !RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS! ^ -sasl errlog_type error ^ -sasl sasl_error_logger false ^ --rabbit error_logger {file,\""!RABBITMQ_LOGS:\=/!"\"} ^ --rabbit sasl_error_logger {file,\""!RABBITMQ_SASL_LOGS:\=/!"\"} ^ +-rabbit lager_log_root \""!RABBITMQ_LOG_BASE:\=/!"\" ^ +-rabbit lager_handler !RABBIT_LAGER_HANDLER! ^ -rabbit enabled_plugins_file \""!RABBITMQ_ENABLED_PLUGINS_FILE:\=/!"\" ^ -rabbit plugins_dir \""!RABBITMQ_PLUGINS_DIR:\=/!"\" ^ -rabbit plugins_expand_dir \""!RABBITMQ_PLUGINS_EXPAND_DIR:\=/!"\" ^ From b8b24048ec5eb35cfe87e1ea1d95bc518f66214e Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Thu, 4 Feb 2016 02:27:09 +0300 Subject: [PATCH 03/17] Add emitting node info to amq.rabbitmq.log messages Fixes #595. --- src/rabbit_error_logger.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rabbit_error_logger.erl b/src/rabbit_error_logger.erl index bbaf9577f946..d8472842430b 100644 --- a/src/rabbit_error_logger.erl +++ b/src/rabbit_error_logger.erl @@ -104,9 +104,11 @@ publish1(RoutingKey, Format, Data, LogExch) -> Timestamp = time_compat:os_system_time(seconds), Args = [truncate:term(A, ?LOG_TRUNC) || A <- Data], + Headers = [{<<"node">>, longstr, list_to_binary(atom_to_list(node()))}], {ok, _DeliveredQPids} = rabbit_basic:publish(LogExch, RoutingKey, #'P_basic'{content_type = <<"text/plain">>, - timestamp = Timestamp}, + timestamp = Timestamp, + headers = Headers}, list_to_binary(io_lib:format(Format, Args))), ok. From 4b08c2875809b05fd5fc8cf2e3c22684a1a6c548 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Thu, 4 Feb 2016 12:34:39 +0100 Subject: [PATCH 04/17] Fix action_stop for the rabbit OCF The action_stop may sometimes stop the rabbitmq-server gracefully by the PID, but leave unresponsive beam.smp processes running and spoiling rabbits. Those shall be stopped as well. The solution is: - make proc_stop() to accept a pid=none to use a name matching instead - make kill_rmq_and_remove_pid() to stop by the beam process matching as well - fix stop_server_process() to ensure there is no beam process left running Related Fuel bug: https://launchpad.net/bugs/1541029 Signed-off-by: Bogdan Dobrelya --- scripts/rabbitmq-server-ha.ocf | 40 +++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/scripts/rabbitmq-server-ha.ocf b/scripts/rabbitmq-server-ha.ocf index 78629547f7d7..5505c105811a 100755 --- a/scripts/rabbitmq-server-ha.ocf +++ b/scripts/rabbitmq-server-ha.ocf @@ -407,8 +407,8 @@ proc_kill() # OCF_SUCCESS # LL # Arguments: -# $1 - pidfile or pid -# $2 - service name used for logging +# $1 - pidfile or pid or 'none', if stopping by the name matching +# $2 - service name used for logging or for the failback stopping method # $3 - stop process timeout (in sec), used to determine how many times we try # SIGTERM and an upper limit on how long this function should try and # stop the process. Defaults to 15. @@ -425,16 +425,20 @@ proc_stop() local i local pid local pidfile - # check if provide just a number - echo "${pid_param}" | egrep -q '^[0-9]+$' - if [ $? -eq 0 ]; then - pid="${pid_param}" - elif [ -e "${pid_param}" ]; then # check if passed in a pid file - pidfile="${pid_param}" - pid=$(cat "${pidfile}" 2>/dev/null | tr -s " " "\n" | sort -u) - else - ocf_log warn "${LH} pid param ${pid_param} is not a file or a number, try match by ${service_name}" + if [ "${pid_param}" = "none" ] ; then pid="none" + else + # check if provide just a number + echo "${pid_param}" | egrep -q '^[0-9]+$' + if [ $? -eq 0 ]; then + pid="${pid_param}" + elif [ -e "${pid_param}" ]; then # check if passed in a pid file + pidfile="${pid_param}" + pid=$(cat "${pidfile}" 2>/dev/null | tr -s " " "\n" | sort -u) + else + ocf_log warn "${LH} pid param ${pid_param} is not a file or a number, try match by ${service_name}" + pid="none" + fi fi # number of times to try a SIGTEM is (timeout - 5 seconds) / 2 seconds local stop_count=$(( ($timeout-5)/2 )) @@ -790,10 +794,14 @@ update_cookie() { return $OCF_SUCCESS } -# Stop rmq beam process by pid or rabbit node name match. Returns SUCCESS/ERROR +# Stop rmq beam process by pid and by rabbit node name match. Returns SUCCESS/ERROR kill_rmq_and_remove_pid() { local LH="${LL} kill_rmq_and_remove_pid():" + # Stop the rabbitmq-server by its pidfile, use the name matching as a fallback, + # and ignore the exit code proc_stop "${OCF_RESKEY_pid_file}" "beam.*${RABBITMQ_NODENAME}" "${OCF_RESKEY_stop_time}" + # Ensure the beam.smp stopped by the rabbit node name matching as well + proc_stop none "beam.*${RABBITMQ_NODENAME}" "${OCF_RESKEY_stop_time}" if [ $? -eq 0 ] ; then return $OCF_SUCCESS else @@ -967,9 +975,11 @@ stop_server_process() { [ $? -eq 0 ] && ocf_log info "${LH} RMQ-server process (PID=${pid}) stopped succesfully." fi - if [ -f ${OCF_RESKEY_pid_file} ] ; then - # Ensure there is no beam process and pidfile left - ocf_log warn "${LH} The pidfile still exists, forcing the RMQ-server cleanup" + # Ensure there is no beam process and pidfile left + pgrep -f "beam.*${RABBITMQ_NODENAME}" > /dev/null + rc=$? + if [ -f ${OCF_RESKEY_pid_file} -o $rc -eq 0 ] ; then + ocf_log warn "${LH} The pidfile or beam's still exist, forcing the RMQ-server cleanup" kill_rmq_and_remove_pid fi From 5cc29e823845fcce3f878eddc1c2f1de84f2f7ba Mon Sep 17 00:00:00 2001 From: Daniil Fedotov Date: Thu, 4 Feb 2016 11:49:03 +0000 Subject: [PATCH 05/17] Log auto deleting queues --- src/rabbit_amqqueue_process.erl | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 1a86851d0ac2..05670774ce82 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -142,6 +142,8 @@ init_it(Recover, From, State = #q{q = #amqqueue{exclusive_owner = Owner}}) -> {_, Terms} = recovery_status(Recover), BQS = bq_init(BQ, Q, Terms), %% Rely on terminate to delete the queue. + log_auto_delete("Exclusive query connection closed", + Owner, State), {stop, {shutdown, missing_owner}, State#q{backing_queue = BQ, backing_queue_state = BQS}} end. @@ -701,7 +703,9 @@ handle_ch_down(DownPid, State = #q{consumers = Consumers, exclusive_consumer = Holder1}, notify_decorators(State2), case should_auto_delete(State2) of - true -> {stop, State2}; + true -> + log_auto_delete("Channel down", DownPid, State), + {stop, State2}; false -> {ok, requeue_and_run(ChAckTags, ensure_expiry_timer(State2))} end @@ -939,6 +943,7 @@ prioritise_call(Msg, _From, _Len, State) -> prioritise_cast(Msg, _Len, State) -> case Msg of delete_immediately -> 8; + {delete_exclusive, _Pid} -> 8; {set_ram_duration_target, _Duration} -> 8; {set_maximum_since_use, _Age} -> 8; {run_backing_queue, _Mod, _Fun} -> 6; @@ -1063,7 +1068,9 @@ handle_call({basic_cancel, ChPid, ConsumerTag, OkMsg}, _From, notify_decorators(State1), case should_auto_delete(State1) of false -> reply(ok, ensure_expiry_timer(State1)); - true -> stop(ok, State1) + true -> + log_auto_delete("basic.cancel request from", ChPid, State), + stop(ok, State1) end end; @@ -1165,6 +1172,10 @@ handle_cast({reject, false, AckTags, ChPid}, State) -> end) end, fun () -> ack(AckTags, ChPid, State) end)); +handle_cast({delete_exclusive, ConnPid}, State) -> + log_auto_delete("Exclusive query connection closed", ConnPid, State), + stop(State); + handle_cast(delete_immediately, State) -> stop(State); @@ -1284,6 +1295,7 @@ handle_info({'DOWN', _MonitorRef, process, DownPid, _Reason}, %% match what people expect (see bug 21824). However we need this %% monitor-and-async- delete in case the connection goes away %% unexpectedly. + log_auto_delete("Exclusive query connection closed", DownPid, State), stop(State); handle_info({'DOWN', _MonitorRef, process, DownPid, _Reason}, State) -> @@ -1347,3 +1359,16 @@ handle_pre_hibernate(State = #q{backing_queue = BQ, {hibernate, stop_rate_timer(State1)}. format_message_queue(Opt, MQ) -> rabbit_misc:format_message_queue(Opt, MQ). + +log_auto_delete(Reason, Owner, State = #q{ q = #amqqueue{ name = Name } }) -> + rabbit_queue:log("Queue deleted automatically: Queue name: ~p Reason: " + ++ Reason ++ " ~p", + [Name, Owner]). + + + + + + + + From d273e9f72b15ed0448461b85fb8fea89fb08b6a1 Mon Sep 17 00:00:00 2001 From: Daniil Fedotov Date: Thu, 4 Feb 2016 18:22:56 +0000 Subject: [PATCH 06/17] Resolve category name to sink name --- src/rabbit_log.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/rabbit_log.erl b/src/rabbit_log.erl index 5eedd925fe43..c0955f5f1877 100644 --- a/src/rabbit_log.erl +++ b/src/rabbit_log.erl @@ -74,10 +74,19 @@ log(Category, Level, Fmt) -> log(Category, Level, Fmt, []). log(Category, Level, Fmt, Args) when is_list(Args) -> Sink = case Category of default -> ?LAGER_SINK; - _ -> lager_util:make_internal_sink_name(Category) + _ -> make_internal_sink_name(Category) end, lager:log(Sink, Level, self(), Fmt, Args). +make_internal_sink_name(Category) when Category == channel; + Category == connection; + Category == mirroring; + Category == queue -> + lager_util:make_internal_sink_name(list_to_atom("rabbit_" ++ + atom_to_list(Category))); +make_internal_sink_name(Category) -> + lager_util:make_internal_sink_name(Category). + debug(Format) -> debug(Format, []). debug(Format, Args) -> debug(self(), Format, Args). debug(Metadata, Format, Args) -> From 4f06877b3adee8d1f39f96d5376aeb6f59c0d16e Mon Sep 17 00:00:00 2001 From: Daniil Fedotov Date: Thu, 4 Feb 2016 18:25:51 +0000 Subject: [PATCH 07/17] Log auto delete with debug level --- src/rabbit_amqqueue_process.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 05670774ce82..93d69af5d96c 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -1361,9 +1361,9 @@ handle_pre_hibernate(State = #q{backing_queue = BQ, format_message_queue(Opt, MQ) -> rabbit_misc:format_message_queue(Opt, MQ). log_auto_delete(Reason, Owner, State = #q{ q = #amqqueue{ name = Name } }) -> - rabbit_queue:log("Queue deleted automatically: Queue name: ~p Reason: " - ++ Reason ++ " ~p", - [Name, Owner]). + rabbit_queue:debug("Queue deleted automatically: Queue name: ~p Reason: " + ++ Reason ++ " ~p", + [Name, Owner]). From c533ae0cfbb962d81ce3f76eb079abcef9e29c1f Mon Sep 17 00:00:00 2001 From: Daniil Fedotov Date: Thu, 4 Feb 2016 18:48:25 +0000 Subject: [PATCH 08/17] Federation log sink --- src/rabbit_log.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rabbit_log.erl b/src/rabbit_log.erl index c0955f5f1877..a22dcbb6f0e1 100644 --- a/src/rabbit_log.erl +++ b/src/rabbit_log.erl @@ -81,7 +81,8 @@ log(Category, Level, Fmt, Args) when is_list(Args) -> make_internal_sink_name(Category) when Category == channel; Category == connection; Category == mirroring; - Category == queue -> + Category == queue; + Category == federation -> lager_util:make_internal_sink_name(list_to_atom("rabbit_" ++ atom_to_list(Category))); make_internal_sink_name(Category) -> From f608e304e0dbeb11154514eb249848e482e1d52f Mon Sep 17 00:00:00 2001 From: Daniil Fedotov Date: Thu, 4 Feb 2016 18:58:10 +0000 Subject: [PATCH 09/17] error_logger_lager_event sink --- src/rabbit_lager.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rabbit_lager.erl b/src/rabbit_lager.erl index 6ae9c10a5e27..8beee1084633 100644 --- a/src/rabbit_lager.erl +++ b/src/rabbit_lager.erl @@ -210,7 +210,8 @@ configure_lager() -> %% messages to the default sink. To know the list of expected extra %% sinks, we look at the 'lager_extra_sinks' compilation option. Sinks0 = application:get_env(lager, extra_sinks, []), - Sinks1 = configure_extra_sinks(Sinks0, list_expected_sinks()), + Sinks1 = configure_extra_sinks(Sinks0, + [error_logger | list_expected_sinks()]), %% TODO Waiting for basho/lager#303 %% Sinks2 = lists:keystore(error_logger_lager_event, 1, Sinks1, %% {error_logger_lager_event, From c7e8d67416a88b627f97c77932d64ed385581404 Mon Sep 17 00:00:00 2001 From: Daniil Fedotov Date: Thu, 4 Feb 2016 19:01:22 +0000 Subject: [PATCH 10/17] Remove rabbitmq fork of lager dependency --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index d42890acc8c3..026c05edb468 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,6 @@ PACKAGES_DIR ?= $(abspath PACKAGES) DEPS = ranch lager $(PLUGINS) -dep_lager = git https://github.com/rabbitmq/lager.git master - define usage_xml_to_erl $(subst __,_,$(patsubst $(DOCS_DIR)/rabbitmq%.1.xml, src/rabbit_%_usage.erl, $(subst -,_,$(1)))) endef From 7a062e5f5cb1c8caf59d06680c1a015a30fdbe6c Mon Sep 17 00:00:00 2001 From: Daniil Fedotov Date: Fri, 5 Feb 2016 16:05:42 +0000 Subject: [PATCH 11/17] Fix wording --- src/rabbit_amqqueue_process.erl | 35 +++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 93d69af5d96c..e3f2a9fc1b32 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -142,8 +142,7 @@ init_it(Recover, From, State = #q{q = #amqqueue{exclusive_owner = Owner}}) -> {_, Terms} = recovery_status(Recover), BQS = bq_init(BQ, Q, Terms), %% Rely on terminate to delete the queue. - log_auto_delete("Exclusive query connection closed", - Owner, State), + log_delete_exclusive(Owner, State), {stop, {shutdown, missing_owner}, State#q{backing_queue = BQ, backing_queue_state = BQS}} end. @@ -704,7 +703,12 @@ handle_ch_down(DownPid, State = #q{consumers = Consumers, notify_decorators(State2), case should_auto_delete(State2) of true -> - log_auto_delete("Channel down", DownPid, State), + log_auto_delete( + io_lib:format( + "because it's last consumer channel was closed"++ + " with ~p consumers", + [length(ChCTags)]), + State), {stop, State2}; false -> {ok, requeue_and_run(ChAckTags, ensure_expiry_timer(State2))} @@ -1069,7 +1073,11 @@ handle_call({basic_cancel, ChPid, ConsumerTag, OkMsg}, _From, case should_auto_delete(State1) of false -> reply(ok, ensure_expiry_timer(State1)); true -> - log_auto_delete("basic.cancel request from", ChPid, State), + log_auto_delete( + io_lib:format( + "because its last consumer ~s was cancelled", + [ConsumerTag]), + State), stop(ok, State1) end end; @@ -1173,7 +1181,7 @@ handle_cast({reject, false, AckTags, ChPid}, State) -> fun () -> ack(AckTags, ChPid, State) end)); handle_cast({delete_exclusive, ConnPid}, State) -> - log_auto_delete("Exclusive query connection closed", ConnPid, State), + log_delete_exclusive(ConnPid, State), stop(State); handle_cast(delete_immediately, State) -> @@ -1295,7 +1303,7 @@ handle_info({'DOWN', _MonitorRef, process, DownPid, _Reason}, %% match what people expect (see bug 21824). However we need this %% monitor-and-async- delete in case the connection goes away %% unexpectedly. - log_auto_delete("Exclusive query connection closed", DownPid, State), + log_delete_exclusive(DownPid, State), stop(State); handle_info({'DOWN', _MonitorRef, process, DownPid, _Reason}, State) -> @@ -1360,10 +1368,17 @@ handle_pre_hibernate(State = #q{backing_queue = BQ, format_message_queue(Opt, MQ) -> rabbit_misc:format_message_queue(Opt, MQ). -log_auto_delete(Reason, Owner, State = #q{ q = #amqqueue{ name = Name } }) -> - rabbit_queue:debug("Queue deleted automatically: Queue name: ~p Reason: " - ++ Reason ++ " ~p", - [Name, Owner]). +log_delete_exclusive(ConPid, #q{ q = #amqqueue{ name = Resource } }) -> + #resource{ name = QName, virtual_host = VHost } = Resource, + rabbit_queue:error("Deleting exclusive queue '~s' for vhost '~s' " ++ + " because it's declaring connection ~p was closed", + [QName, VHost, ConPid]). + +log_auto_delete(Reason, #q{ q = #amqqueue{ name = Resource } }) -> + #resource{ name = QName, virtual_host = VHost } = Resource, + rabbit_queue:error("Deleting auto-delete queue '~s' on vhost '~s' " ++ + Reason, + [QName, VHost]). From 9d6e514a9ead6d784a939fe52e798dcd21d5c519 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Fri, 5 Feb 2016 19:31:18 +0300 Subject: [PATCH 12/17] Copy --- src/rabbit_amqqueue_process.erl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index e3f2a9fc1b32..2f82b72d0377 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -705,8 +705,7 @@ handle_ch_down(DownPid, State = #q{consumers = Consumers, true -> log_auto_delete( io_lib:format( - "because it's last consumer channel was closed"++ - " with ~p consumers", + "because all ~p of its consumers were on a channel that was closed", [length(ChCTags)]), State), {stop, State2}; @@ -1370,8 +1369,8 @@ format_message_queue(Opt, MQ) -> rabbit_misc:format_message_queue(Opt, MQ). log_delete_exclusive(ConPid, #q{ q = #amqqueue{ name = Resource } }) -> #resource{ name = QName, virtual_host = VHost } = Resource, - rabbit_queue:error("Deleting exclusive queue '~s' for vhost '~s' " ++ - " because it's declaring connection ~p was closed", + rabbit_queue:error("Deleting exclusive queue '~s' in vhost '~s' " ++ + " because its declaring connection ~p was closed", [QName, VHost, ConPid]). log_auto_delete(Reason, #q{ q = #amqqueue{ name = Resource } }) -> From 8e4715b91cec879335b70fccd0fd4e5c9ceb25d7 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Fri, 5 Feb 2016 19:34:35 +0300 Subject: [PATCH 13/17] Grammar --- src/rabbit_amqqueue_process.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 2f82b72d0377..fc1a5399863c 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -1375,7 +1375,7 @@ log_delete_exclusive(ConPid, #q{ q = #amqqueue{ name = Resource } }) -> log_auto_delete(Reason, #q{ q = #amqqueue{ name = Resource } }) -> #resource{ name = QName, virtual_host = VHost } = Resource, - rabbit_queue:error("Deleting auto-delete queue '~s' on vhost '~s' " ++ + rabbit_queue:error("Deleting auto-delete queue '~s' in vhost '~s' " ++ Reason, [QName, VHost]). From 41c6ec56c5829286551906c9ddd23fa0a166f9fd Mon Sep 17 00:00:00 2001 From: Daniil Fedotov Date: Fri, 5 Feb 2016 16:43:24 +0000 Subject: [PATCH 14/17] Logging queue deletion at debug level --- src/rabbit_amqqueue_process.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index fc1a5399863c..d824a1e22d3e 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -1369,13 +1369,13 @@ format_message_queue(Opt, MQ) -> rabbit_misc:format_message_queue(Opt, MQ). log_delete_exclusive(ConPid, #q{ q = #amqqueue{ name = Resource } }) -> #resource{ name = QName, virtual_host = VHost } = Resource, - rabbit_queue:error("Deleting exclusive queue '~s' in vhost '~s' " ++ + rabbit_queue:debug("Deleting exclusive queue '~s' in vhost '~s' " ++ " because its declaring connection ~p was closed", [QName, VHost, ConPid]). log_auto_delete(Reason, #q{ q = #amqqueue{ name = Resource } }) -> #resource{ name = QName, virtual_host = VHost } = Resource, - rabbit_queue:error("Deleting auto-delete queue '~s' in vhost '~s' " ++ + rabbit_queue:debug("Deleting auto-delete queue '~s' in vhost '~s' " ++ Reason, [QName, VHost]). From cc80a0ce8dab2b8e96c2d0ede17213f0dfdecb7f Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Fri, 5 Feb 2016 20:28:10 +0300 Subject: [PATCH 15/17] More copy edits --- src/rabbit_amqqueue_process.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index d824a1e22d3e..513d4df7861e 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -705,7 +705,7 @@ handle_ch_down(DownPid, State = #q{consumers = Consumers, true -> log_auto_delete( io_lib:format( - "because all ~p of its consumers were on a channel that was closed", + "because all of its consumers (~p) were on a channel that was closed", [length(ChCTags)]), State), {stop, State2}; @@ -1074,7 +1074,7 @@ handle_call({basic_cancel, ChPid, ConsumerTag, OkMsg}, _From, true -> log_auto_delete( io_lib:format( - "because its last consumer ~s was cancelled", + "because its last consumer with tag '~s' was cancelled", [ConsumerTag]), State), stop(ok, State1) @@ -1375,7 +1375,7 @@ log_delete_exclusive(ConPid, #q{ q = #amqqueue{ name = Resource } }) -> log_auto_delete(Reason, #q{ q = #amqqueue{ name = Resource } }) -> #resource{ name = QName, virtual_host = VHost } = Resource, - rabbit_queue:debug("Deleting auto-delete queue '~s' in vhost '~s' " ++ + rabbit_queue:debug("Deleting auto-delete queue '~s' in vhost '~s' " ++ Reason, [QName, VHost]). From e14d56d6e8377ff88356783f4e2ede4a3ce3da4a Mon Sep 17 00:00:00 2001 From: Daniil Fedotov Date: Fri, 5 Feb 2016 18:07:06 +0000 Subject: [PATCH 16/17] Do not log connection ref --- src/rabbit_amqqueue_process.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 513d4df7861e..54fcdfec9ff9 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -1367,11 +1367,11 @@ handle_pre_hibernate(State = #q{backing_queue = BQ, format_message_queue(Opt, MQ) -> rabbit_misc:format_message_queue(Opt, MQ). -log_delete_exclusive(ConPid, #q{ q = #amqqueue{ name = Resource } }) -> +log_delete_exclusive(_ConPid, #q{ q = #amqqueue{ name = Resource } }) -> #resource{ name = QName, virtual_host = VHost } = Resource, rabbit_queue:debug("Deleting exclusive queue '~s' in vhost '~s' " ++ - " because its declaring connection ~p was closed", - [QName, VHost, ConPid]). + " because its declaring connection was closed", + [QName, VHost]). log_auto_delete(Reason, #q{ q = #amqqueue{ name = Resource } }) -> #resource{ name = QName, virtual_host = VHost } = Resource, From e9ee125aecee9cdd61a4b8f48cdd3849a8bb439d Mon Sep 17 00:00:00 2001 From: Daniil Fedotov Date: Fri, 5 Feb 2016 19:28:17 +0000 Subject: [PATCH 17/17] Log connection pid only --- src/rabbit_amqqueue_process.erl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 54fcdfec9ff9..f79304632e64 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -1367,11 +1367,13 @@ handle_pre_hibernate(State = #q{backing_queue = BQ, format_message_queue(Opt, MQ) -> rabbit_misc:format_message_queue(Opt, MQ). -log_delete_exclusive(_ConPid, #q{ q = #amqqueue{ name = Resource } }) -> +log_delete_exclusive({ConPid, ConRef}, State) -> + log_delete_exclusive(ConPid, State); +log_delete_exclusive(ConPid, #q{ q = #amqqueue{ name = Resource } }) -> #resource{ name = QName, virtual_host = VHost } = Resource, rabbit_queue:debug("Deleting exclusive queue '~s' in vhost '~s' " ++ - " because its declaring connection was closed", - [QName, VHost]). + " because its declaring connection ~p was closed", + [QName, VHost, ConPid]). log_auto_delete(Reason, #q{ q = #amqqueue{ name = Resource } }) -> #resource{ name = QName, virtual_host = VHost } = Resource,