Skip to content

Make rabbit_networking:close_connection/2 more benign #1413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

michaelklishin
Copy link
Collaborator

Proposed Changes

The function relies on a fanout to all running cluster nodes
which in turn check their local connection process group.
All errors that might arise are ignored.

There are at least two scenarios where the current behavior makes
little sense:

  • A connection process has just terminated (but is still present in the stats DB)
  • A node could not respond (or respond in time) to the fanout

In both cases claiming that connection pid is "not a connection pid"
is misleading and likely will leave the user puzzled. This change
makes connection_close/2 more benign: it simply logs a warning and returns
instead of throwing.

There are only two call sites that use it: rabbitmqctl and an HTTP API
handler, so the chances of non-connection pids passed in are pretty slim.

While at it, only log that a connection was closed when it actually was.

Per discussion with @gerhard.## Types of Changes

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

  • Bugfix (non-breaking change which fixes issue #NNNN)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (correction or otherwise)
  • Cosmetics (whitespace, appearance)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating
the PR. If you're unsure about any of them, don't hesitate to ask on the
mailing list. We're here to help! This is simply a reminder of what we are
going to look for before merging your code.

  • I have read the CONTRIBUTING.md document
  • I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq)
  • All tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in related repositories

The function relies on a fanout to all running cluster nodes
which in turn check their local connection process group.
All errors that might arise are ignored.

There are at least two scenarios where the current behavior makes
little sense:

 * A connection process has just terminated (but is still present in the stats DB)
 * A node could not respond (or respond in time) to the fanout

In both cases claiming that connection pid is "not a connection pid"
is misleading and likely will leave the user puzzled. This change
makes connection_close/2 more benign: it simply logs a warning and returns
instead of throwing.

There are only two call sites that use it: rabbitmqctl and an HTTP API
handler, so the chances of non-connection pids passed in are pretty slim.

Per discussion with @gerhard.
@michaelklishin michaelklishin added this to the 3.6.13 milestone Oct 30, 2017
@michaelklishin
Copy link
Collaborator Author

Note: test/close_connection_command_test.exs in rabbitmq-cli must be updated if/when this is merged into master.

@michaelklishin michaelklishin merged commit de5bc6e into stable Oct 31, 2017
michaelklishin added a commit to rabbitmq/rabbitmq-cli that referenced this pull request Oct 31, 2017
@gerhard
Copy link
Contributor

gerhard commented Oct 31, 2017

🎉

@lukebakken lukebakken deleted the mk-dont-throw-when-connection-pid-is-non-local branch October 31, 2017 14:15
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.

3 participants