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

when in backoff, make sure that the chosen connection isn't closing #127

Merged
merged 1 commit into from
Mar 24, 2015
Merged

when in backoff, make sure that the chosen connection isn't closing #127

merged 1 commit into from
Mar 24, 2015

Conversation

jnewmano
Copy link
Contributor

Backoff chooses a random connection and tries to update the ready status; however, if the connection is closing, updateRdy will return immediately, leaving the backoffCounter in a bad state. The side effect is that maybeUpdateRdy will never update the ready count due to the incorrect backoffCounter and the consumer will never again consume messages.

@jnewmano
Copy link
Contributor Author

It seems like a case that the fix for #106 did not cover.

@jnewmano
Copy link
Contributor Author

It may be better (and avoid a potential race) to have updateRdy return an error if c.IsClosing() and have backoff handle the error appropriately.

@mreiferson
Copy link
Member

Was going to suggest the same, want to give that a try?

Thanks for finding this!

@jnewmano
Copy link
Contributor Author

I made the switch to checking the returned error.

On consumer.go line 694 clears backoffDuration perhaps momentarily. It may be better to move it to the end of backoff(), after backoff is successful? This would avoid mistakenly sending false to a call to inBackoffBlock()

https://github.com/jnewmano/go-nsq/blob/master/consumer.go#L694

@@ -709,11 +709,29 @@ func (r *Consumer) backoff() {
idx := r.rng.Intn(len(conns))
choice := conns[idx]

// make sure the chosen connection isn't closing
if choice.IsClosing() {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this block anymore, do we?

@mreiferson
Copy link
Member

On consumer.go line 694 clears backoffDuration perhaps momentarily. It may be better to move it to the end of backoff(), after backoff is successful? This would avoid mistakenly sending false to a call to inBackoffBlock()

SGTM

Check updateRDY return error, clear backoffDuration on success

in backoff, check error status of updateRDY
@mreiferson
Copy link
Member

LGTM

mreiferson added a commit that referenced this pull request Mar 24, 2015
when in backoff, make sure that the chosen connection isn't closing
@mreiferson mreiferson merged commit 33e8317 into nsqio:master Mar 24, 2015
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