Skip to content

Handle a race condition when a closing channel/connection fails to send 'channel.close_ok' on a terminated writer or socket#16651

Merged
michaelklishin merged 7 commits into
rabbitmq:mainfrom
Ayanda-D:ready-for-close-catch
Jun 10, 2026
Merged

Handle a race condition when a closing channel/connection fails to send 'channel.close_ok' on a terminated writer or socket#16651
michaelklishin merged 7 commits into
rabbitmq:mainfrom
Ayanda-D:ready-for-close-catch

Conversation

@Ayanda-D

Copy link
Copy Markdown
Contributor

Proposed Changes

We see a race condition when a closing channel/connection fails to send 'channel.close_ok' to a client when the writer and/or socket is already closed or terminated.

2026-06-04 17:20:27.578719-04:00 [error] <0.20291977.0> ** Generic server <0.20291977.0> terminating
2026-06-04 17:20:27.578719-04:00 [error] <0.20291977.0> ** Last message in was {'$gen_cast',ready_for_close}
2026-06-04 17:20:27.578719-04:00 [error] <0.20291977.0> ** When Server state == {ch,
2026-06-04 17:20:27.578719-04:00 [error] <0.20291977.0>                          {conf,closing,rabbit_framing_amqp_0_9_1,1,
2026-06-04 17:20:27.578719-04:00 [error] <0.20291977.0>                           <0.20291963.0>,<0.20291984.0>,<0.20291963.0>,
...
...
...
2026-06-04 17:20:27.578719-04:00 [error] <0.20291977.0>                                go,1,2,false,#{},#{},#{},undefined,
2026-06-04 17:20:27.578719-04:00 [error] <0.20291977.0>                                undefined}}}},
2026-06-04 17:20:27.578719-04:00 [error] <0.20291977.0>                          #Ref<0.1993375891.2291138563.124715>,true}
2026-06-04 17:20:27.578719-04:00 [error] <0.20291977.0> ** Reason for termination ==
2026-06-04 17:20:27.578719-04:00 [error] <0.20291977.0> ** {{shutdown,{writer,send_failed,closed}},
2026-06-04 17:20:27.578719-04:00 [error] <0.20291977.0>     {gen_server,call,
2026-06-04 17:20:27.578719-04:00 [error] <0.20291977.0>                 [<0.20291984.0>,
2026-06-04 17:20:27.578719-04:00 [error] <0.20291977.0>                  {send_command_sync,{'channel.close_ok'}},
2026-06-04 17:20:27.578719-04:00 [error] <0.20291977.0>                  infinity]}}
2026-06-04 17:20:27.578719-04:00 [error] <0.20291977.0>
2026-06-04 17:20:27.579447-04:00 [error] <0.20291977.0>   crasher:
2026-06-04 17:20:27.579447-04:00 [error] <0.20291977.0>     initial call: rabbit_channel:init/1
2026-06-04 17:20:27.579447-04:00 [error] <0.20291977.0>     pid: <0.20291977.0>
2026-06-04 17:20:27.579447-04:00 [error] <0.20291977.0>     registered_name: []
2026-06-04 17:20:27.579447-04:00 [error] <0.20291977.0>     exception exit: {{shutdown,{writer,send_failed,closed}},
2026-06-04 17:20:27.579447-04:00 [error] <0.20291977.0>                      {gen_server,call,
2026-06-04 17:20:27.579447-04:00 [error] <0.20291977.0>                                  [<0.20291984.0>,
2026-06-04 17:20:27.579447-04:00 [error] <0.20291977.0>                                   {send_command_sync,{'channel.close_ok'}},
2026-06-04 17:20:27.579447-04:00 [error] <0.20291977.0>                                   infinity]}}

Similar to #16598 we'd like to handle these channel terminations and crashes in a more graceful manner.

Types of Changes

What types of changes does your code introduce to this project?
Put an x in the boxes that apply

  • Bug fix (non-breaking change which fixes issue #NNNN)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause an observable behavior change in existing systems)
  • Documentation improvements (corrections, new content, etc)
  • Cosmetic change (whitespace, formatting, etc)
  • Build system and/or CI

Checklist

Put an x in the boxes that apply.
You can also fill these out after creating the PR.
This is simply a reminder of what we are going to look for before merging your code.

@mergify mergify Bot added the make label Jun 10, 2026
@michaelklishin
michaelklishin merged commit 2bd3449 into rabbitmq:main Jun 10, 2026
196 of 197 checks passed
michaelklishin added a commit that referenced this pull request Jun 10, 2026
michaelklishin added a commit that referenced this pull request Jun 15, 2026
`4.3.3`: Handle a race condition when a closing channel/connection fails to send 'channel.close_ok' on a terminated writer or socket (backport #16651)
michaelklishin added a commit that referenced this pull request Jun 16, 2026
`4.3.3`: Handle a race condition when a closing channel/connection fails to send 'channel.close_ok' on a terminated writer or socket (backport #16651) (backport #16655)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants