Skip to content

Wrapped concurrentqueue + semaphore pair together for readability, an… #761

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

michac
Copy link
Contributor

@michac michac commented Mar 17, 2020

…d unblocked recovery main loop during retry delay.

Proposed Changes

In the process of changing the AutorecoveringConnection to run via the TPL versus having its own dedicated thread I noticed that the Task.Delay operations for recovery retries were being awaited. My expectation with the RecoveryLoop was that it would be able to process commands that came in during the delay, which it cannot do if it's awaiting the delay inside of a command handler.

I also think that if we're awaiting a Task.Delay without passing it a cancellation token then we won't be able to easily cancel out of an auto-recovering connection that's in a Delay, it will instead timeout in StopRecoveryLoop if RequestConnectionTimeout is less than NetworkRecoveryInterval and log a warning. I solved this by not awaiting the Task.Delay operation, it could also be solved by passing a CancellationToken.

Also I wrapped the semaphore and concurrentqueue together in a class to clarify that they were acting together (i.e. Enqueue should be followed by semaphore.Release()). This improved the readability in my opinion, but I'd be happy to take this part out if it's not popular.

Types of Changes

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

  • [ x] Bug fix (non-breaking change which fixes issue #NNNN)
  • [ x] 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)

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.

  • [ x] I have read the CONTRIBUTING.md document
  • [ x] 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

Further Comments

This is an identical copy of #752 , I just squashed the 6 commits to one to make it less noisy. Feel free to dismiss this or the other one to get the count back to one. I also updated to a personal fork instead of one in my organization, to see if that made it possible for others to push changes. @lukebakken

…d unblocked recovery main loop during retry delay.
@michaelklishin
Copy link
Contributor

Is this still relevant given the recent changes such as #772 and #775?

@michaelklishin
Copy link
Contributor

OK, I see what this really affects, so it seems to be relevant.

@michaelklishin michaelklishin merged commit 8a46f95 into rabbitmq:master Mar 26, 2020
@bording
Copy link
Collaborator

bording commented Mar 26, 2020

@michaelklishin This was something I was still planning on taking a closer look at. I'll still try to do that and if I see anything important.

@michaelklishin
Copy link
Contributor

@bording oh, OK, sorry. We can always amend this PR, of course.

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.

4 participants