-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Terminate channels and queue collector after reader
What? To not risk any regressions, keep the behaviour of RabbitMQ 3.x where channel processes and connection helper processes such as rabbit_queue_collector and rabbit_heartbeat are terminated after rabbit_reader process. For example, when RabbitMQ terminates with SIGTERM, we want exclusive queues being deleted synchronously (as in 3.x). Prior to this commit: 1. java -jar target/perf-test.jar -x 0 -y 1 2. ./sbin/rabbitmqctl stop_app resulted in the following crash: ``` crasher: initial call: rabbit_reader:init/2 pid: <0.2389.0> registered_name: [] exception exit: {noproc, {gen_server,call,[<0.2391.0>,delete_all,infinity]}} in function gen_server:call/3 (gen_server.erl, line 419) in call from rabbit_reader:close_connection/1 (rabbit_reader.erl, line 683) in call from rabbit_reader:send_error_on_channel0_and_close/4 (rabbit_reader.erl, line 1668) in call from rabbit_reader:handle_dependent_exit/3 (rabbit_reader.erl, line 710) in call from rabbit_reader:mainloop/4 (rabbit_reader.erl, line 530) in call from rabbit_reader:run/1 (rabbit_reader.erl, line 452) in call from rabbit_reader:start_connection/4 (rabbit_reader.erl, line 351) ``` because rabbit_queue_collector was terminated before rabbit_reader. This commit fixes this crash. How? Any Erlang supervisor including the rabbit_connection_sup supervisor terminates its children in the opposite of the start order. Since we want channel and queue collector processes - children of rabbit_connection_helper_sup - be terminated after the reader process, we must start rabbit_connection_helper_sup before the reader process. Since rabbit_connection_sup - the ranch_protocol implementation - does not know yet whether it will supervise an AMQP 0.9.1 or AMQP 1.0 connection, it creates rabbit_connection_helper_sup for each AMQP protocol version removing the superfluous one as soon as the protocol version negotation is completed. Spawning and deleting this addition process has a negligible effect on performance. The whole problem is that the rabbit_connection_helper_sup differs in its supervisor flags for AMQP 0.9.1 and AMQP 1.0 when it is started because for Native AMQP 1.0 in 4.0 we remove the unnecessary rabbit_amqp1_0_session_sup_sup supervisor level. Therefore, we achieve our goal: * in Native AMQP 1.0, 1 additional Erlang process is created per session * in AMQP 1.0 in 3.x, 15 additional Erlang processes are created per session
- Loading branch information
Showing
3 changed files
with
67 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters