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

Don't use activeContext for standby/leader cancelation #4919

Merged
merged 1 commit into from
Jul 13, 2018
Merged

Don't use activeContext for standby/leader cancelation #4919

merged 1 commit into from
Jul 13, 2018

Conversation

sethvargo
Copy link
Contributor

Move cancelation to after cleanup. This is my guess as to what's happening here, but I could be totally off base.

It looks like we call cancelation on activeContext, but then pass that context to the function. I moved the cancelation to after cleanup, and made context a local param to reduce the chance of a race if another func modifies c.activeContext

/cc @briankassouf @jefferai

Fixes GH-4915

vault/ha.go Outdated
c.logger.Error("clearing leader advertisement failed", "error", err)
}
c.heldHALock.Unlock()
c.heldHALock = nil
}

// Tell any requests that know about this to stop
if c.activeContextCancelFunc != nil {
c.activeContextCancelFunc()
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you move this back where it was, it's designed to stop all pending requests prior to grabbing the lock.

Copy link
Member

Choose a reason for hiding this comment

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

I think all this PR needs to be is a single line changing c.activeContext in clearLeader to context.Background().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@briankassouf moved it back up - sorry I misunderstood.

@jefferai I like having ctx as the first argument to clearLeader, since that's "the Go way", but I updated it to use its own context.Background() instantiated just before the call.

@jefferai
Copy link
Member

@sethvargo it's only "the Go way" if you have a context you actually need to pass. In this case there isn't a context -- we're using the Background one because no other context makes sense. So it shouldn't be passed into clearLeader, because clearLeader doesn't need it.

Move cancelation to after cleanup

Fixes GH-4915
@sethvargo
Copy link
Contributor Author

@jefferai okay updated

@jefferai
Copy link
Member

👍

@jefferai jefferai merged commit be84781 into hashicorp:master Jul 13, 2018
@sethvargo sethvargo deleted the sethvargo/hactx branch July 13, 2018 16:00
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