Skip to content

AMQP 1.0 client: gracefully handle connection termination in more places (backport #17013)#17015

Merged
mkuratczyk merged 1 commit into
v4.3.xfrom
mergify/bp/v4.3.x/pr-17013
Jul 23, 2026
Merged

AMQP 1.0 client: gracefully handle connection termination in more places (backport #17013)#17015
mkuratczyk merged 1 commit into
v4.3.xfrom
mergify/bp/v4.3.x/pr-17013

Conversation

@mergify

@mergify mergify Bot commented Jul 23, 2026

Copy link
Copy Markdown

This should address some function_clause errors observed when using AMQP 1.0 shovels.

  reason: {function_clause,
              [{amqp10_client_connection,hdr_sent,
                   [info,
                    {'DOWN',#Ref<0.2037148225.2260205569.233493>,process,
                        <0.29675.0>,normal},
                    {state,0,<0.29672.0>,
                        #Ref<0.2037148225.2260205569.233493>,<0.29676.0>,
                        [{<0.29530.0>,
                          [alias|
                           #Ref<0.0.3779843.2037148225.2260271105.233488>]}],
                        <0.29675.0>,
                        {tcp,#Port<0.396>},
                        undefined,undefined,
                        #{notify => <0.29530.0>,port => 5672,
                          address => "green",
                          sasl =>
                              {encrypted,
                                  <<"6APRufcR3aNjXGKFDynwAyf37GF3YqrJq06ecxGXPXNcdqSEXEKXoitUXhMTLBRhzdnWAQmdu9lw2aZ5TlxChT04sNM7XiCPZVhVFwKI124OLrxsEKjS0zOvYZc8wAlT02XqNHL4HGv9YHRGNX2aFpYCsLVTdEL4yRA8COvRomXsCDuCJ1XpWNvo/Y6fTjkW9PzfZiOwPWyfyvBx2nVCMw==">>},
                          hostname => <<"green">>,
                          properties =>
                              #{<<"ignore-maintenance">> => {boolean,true}},
                          notify_when_opened => <0.29530.0>,
                          notify_when_closed => <0.29530.0>,
                          transfer_limit_margin => 0,
                          max_frame_size => 1048576}}],
                   [{file,"amqp10_client_connection.erl"},{line,244}]},
               {gen_statem,loop_state_callback,11,
                   [{file,"gen_statem.erl"},{line,3735}]},
               {proc_lib,init_p_do_apply,3,
                   [{file,"proc_lib.erl"},{line,329}]}]}
  reason: {function_clause,
               [{amqp10_client_connection,close_sent,
                    [info,
                     {'EXIT',<0.11280.0>,killed},
                     {state,1,<0.11283.0>,
                         #Ref<0.1827165118.3650617346.181159>,<0.11287.0>,[],
                         <0.11285.0>,
                         {tcp,#Port<0.308>},
                         15000,
                         {once,#Ref<0.1827165118.3651141633.134174>},
                         #{notify => <0.11280.0>,port => 5672,
                           address => "green",
                           hostname => <<"green">>,
                           notify_when_opened => <0.11280.0>,
                           notify_when_closed => <0.11280.0>}}],
                    [{file,"amqp10_client_connection.erl"},{line,350}]},
                {gen_statem,loop_state_callback,11,
                    [{file,"gen_statem.erl"},{line,3735}]},
                {proc_lib,init_p_do_apply,3,
                    [{file,"proc_lib.erl"},{line,329}]}]}
```<hr>This is an automatic backport of pull request #17013 done by [Mergify](https://mergify.com).

…ces (#17013)

* amqp10_client: handle DOWN in more states

When running AMQP 1.0 shovels, sometimes they would crash with errors
like this:

```
  reason: {function_clause,
              [{amqp10_client_connection,hdr_sent,
                   [info,
                    {'DOWN',#Ref<0.2037148225.2260205569.233493>,process,
                        <0.29675.0>,normal},
                    {state,0,<0.29672.0>,
                        #Ref<0.2037148225.2260205569.233493>,<0.29676.0>,
                        [{<0.29530.0>,
                          [alias|
                           #Ref<0.0.3779843.2037148225.2260271105.233488>]}],
                        <0.29675.0>,
                        {tcp,#Port<0.396>},
                        undefined,undefined,
                        #{notify => <0.29530.0>,port => 5672,
                          address => "green",
                          sasl =>
                              {encrypted,
                                  <<"6APRufcR3aNjXGKFDynwAyf37GF3YqrJq06ecxGXPXNcdqSEXEKXoitUXhMTLBRhzdnWAQmdu9lw2aZ5TlxChT04sNM7XiCPZVhVFwKI124OLrxsEKjS0zOvYZc8wAlT02XqNHL4HGv9YHRGNX2aFpYCsLVTdEL4yRA8COvRomXsCDuCJ1XpWNvo/Y6fTjkW9PzfZiOwPWyfyvBx2nVCMw==">>},
                          hostname => <<"green">>,
                          properties =>
                              #{<<"ignore-maintenance">> => {boolean,true}},
                          notify_when_opened => <0.29530.0>,
                          notify_when_closed => <0.29530.0>,
                          transfer_limit_margin => 0,
                          max_frame_size => 1048576}}],
                   [{file,"amqp10_client_connection.erl"},{line,244}]},
               {gen_statem,loop_state_callback,11,
                   [{file,"gen_statem.erl"},{line,3735}]},
               {proc_lib,init_p_do_apply,3,
                   [{file,"proc_lib.erl"},{line,329}]}]}
```

* amqp10_client: handle unexpected EXIT reasons in close_sent

Connections linked by their owner (e.g. AMQP 1.0 shovels call
link/1 on the connection PID) could crash with a function_clause
error if that owner exited with a reason other than shutdown while
the connection was in the close_sent state:

```
  reason: {function_clause,
               [{amqp10_client_connection,close_sent,
                    [info,
                     {'EXIT',<0.11280.0>,killed},
                     {state,1,<0.11283.0>,
                         #Ref<0.1827165118.3650617346.181159>,<0.11287.0>,[],
                         <0.11285.0>,
                         {tcp,#Port<0.308>},
                         15000,
                         {once,#Ref<0.1827165118.3651141633.134174>},
                         #{notify => <0.11280.0>,port => 5672,
                           address => "green",
                           hostname => <<"green">>,
                           notify_when_opened => <0.11280.0>,
                           notify_when_closed => <0.11280.0>}}],
                    [{file,"amqp10_client_connection.erl"},{line,350}]},
                {gen_statem,loop_state_callback,11,
                    [{file,"gen_statem.erl"},{line,3735}]},
                {proc_lib,init_p_do_apply,3,
                    [{file,"proc_lib.erl"},{line,329}]}]}
```

close_sent/3 only matched EXIT signals with reason shutdown or
{shutdown, _}, which is what our own supervisor sends when it wants
us to terminate gracefully within its own timeout. Any other EXIT
reason, such as an owning process being killed, now stops the
connection instead, mirroring how we already give up waiting for a
close frame when the reader process goes down.

(cherry picked from commit f815505)
@mergify

mergify Bot commented Jul 23, 2026

Copy link
Copy Markdown
Author

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@mkuratczyk
mkuratczyk merged commit d78ada1 into v4.3.x Jul 23, 2026
186 checks passed
@mkuratczyk
mkuratczyk deleted the mergify/bp/v4.3.x/pr-17013 branch July 23, 2026 09:35
@michaelklishin michaelklishin added this to the 4.3.4 milestone Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants