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

reset watch's lastIndex on error #2621

Merged
merged 3 commits into from
Jun 2, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions watch/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ OUTER:
if err != nil {
// Perform an exponential backoff
failures++
p.lastIndex = 1
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this'll catch all cases since you won't always get an error. It's probably better to add something down on line 88 like this:

if p.lastIndex < oldIndex {
    p.lastIndex = 0
}

This'll reset the blocking query whenever the index slips backwards.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for your reply, @slackpad.

The original fix I can easily reproduce in a test setup (watch() something and restart the Consul server in -dev mode), but a index which goes back (but doesn't drop the connection) I can't test. So I've added the lines you suggested, but I can't test it.

I also changed my original fix to reset the index to 0, not to 1.

(if this is fine I'll squash all commits)

retry := retryInterval * time.Duration(failures*failures)
if retry > maxBackoffTime {
retry = maxBackoffTime
Expand Down