Skip to content
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

consumer: Reset backoff counter when no connections left. #106

Merged
merged 1 commit into from
Feb 3, 2015
Merged

consumer: Reset backoff counter when no connections left. #106

merged 1 commit into from
Feb 3, 2015

Conversation

ryanslade
Copy link
Contributor

This fixes the following scenario:

  1. Consumer is connected to one NSQD host using ConnectToNSQD.
  2. Consumer receives message and handler returns an error.
  3. Consumer backs off.
  4. DisconnectFromNSQD called before backoff closure wakes up.
  5. Backoff closure wakes up, sees no connections, returns.
  6. Consumer connects to NSQD host using ConnectToNSQD.
  7. backoffCounter still > 0 so never sends RDY count (in
    maybeUpdateRDY).
  8. Consumer is now stuck and never sends RDY > 0.

@jehiah jehiah added the bug label Feb 2, 2015
if r.backoffCounter > 0 {
r.backoffCounter--
}
r.backoffMtx.Unlock()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for identifying this bug.

Unfortunately, I'm not convinced this is the right fix. I think the correct behavior should be for this to loop until it has a connection (also paying attention to an exit signal), and then send RDY 1.

Thoughts @jehiah

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we treat backoff as backing off from downstream systems, then i agree. It should persist beyond upstream nsqd reconnects

Since this code block is in a time.After we should be able to refactor to just re-set that function recursively (and have it end on exit flags appropriately).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have some time to work on a fix tomorrow (GMT).

@mreiferson
Copy link
Member

this LGTM, mind squashing the commits down?

This fixes the following scenario:
1. Consumer is connected to one NSQD host using ConnectToNSQD.
2. Consumer receives message and handler returns an error.
3. Consumer backs off.
4. DisconnectFromNSQD called before backoff closure wakes up.
5. Backoff closure wakes up, sees no connections, returns.
6. Consumer connects to NSQD host using ConnectToNSQD.
7. backoffCounter still > 0 so never sends RDY count (in
maybeUpdateRDY).
8. Consumer is now stuck and never sends RDY > 0.
@ryanslade
Copy link
Contributor Author

Squashed :)

mreiferson added a commit that referenced this pull request Feb 3, 2015
consumer: Reset backoff counter when no connections left.
@mreiferson mreiferson merged commit 59eba58 into nsqio:master Feb 3, 2015
@mreiferson
Copy link
Member

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants