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

Fix policy creation race #29

Merged
merged 1 commit into from
Apr 4, 2019
Merged

Fix policy creation race #29

merged 1 commit into from
Apr 4, 2019

Conversation

jefferai
Copy link
Member

@jefferai jefferai commented Apr 4, 2019

Calling policy creates on first use, so if your first access (even a
read) of the plugin comes from a secondary you get a read only error
message. This runs policy creation as a part of the upgrade path and
adds a check to ensure it's been run.

This was tripping during the existence check, since to read metadata it creates a path encryptor except we don't forward existence checks due to read only errors.

read) of the plugin comes from a secondary you get a read only error
message. This runs policy creation as a part of the upgrade path and
adds a check to ensure it's been run.
@jefferai jefferai merged commit 79cbd43 into master Apr 4, 2019
@jefferai jefferai deleted the policy-creation-race branch April 4, 2019 20:53

if upgradeInfo.Done {
// Just synchronously call policy
if _, err = b.policy(ctx, s); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I see a warning about "The caller must have the backend lock." in policy(). Applies in the upgrade case too?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point -- It's fine in the non-goroutine case because it's synchronous during backend factory creation. But if we don't run it then, and end up running it in the goroutine, then we don't have the lock at that time. This the presents an issue, because if we aren't upgraded, if we write the policy it'll be considered by the upgrade logic to be existing data and will be moved. So it has to be done after upgrading. But in the meantime clients can make calls that can then indirectly call policy. So I may indeed have to wrap the second invocation (in the goroutine) in a lock and it's just best effort. That said since secondaries will wait for the write of the upgrade done canary anyways probably they'll block client access until then so it'll be fine just moving that block up a bit.

briankassouf pushed a commit that referenced this pull request Apr 15, 2019
briankassouf added a commit that referenced this pull request Apr 16, 2019
* Undo the changes from #29

* Don't bubble up readonly errors on standbys
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