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

Add transaction-like behavior for Transit persists. #3959

Merged
merged 5 commits into from
Feb 12, 2018

Conversation

jefferai
Copy link
Member

@jefferai jefferai commented Feb 12, 2018

This ensures that in-memory policy matches the state of on-disk policy
if a storage error occurs.

Ref: #2705

This ensures that in-memory policy matches the state of on-disk policy
if a storage error occurs.
@jefferai jefferai changed the title [WIP] Add transaction-like behavior for Transit persists. Add transaction-like behavior for Transit persists. Feb 12, 2018
}
lock.RUnlock()
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing defer in here?

Copy link
Member Author

Choose a reason for hiding this comment

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

This should be unlocked right away. In theory in the rest of the test we should be grabbing a write lock on the policy, but since it's test-scoped and not in parallel we don't.

// roll back keys, but better safe than sorry and this doesn't happen
// enough to worry about the speed tradeoff.
priorArchiveVersion := p.ArchiveVersion
priorKeys := keyEntryMap(nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this use copystructure.Copy(p.Keys) so that we can just do p.Keys = priorKeys.(keyEntryMap) similar do what is being done in Upgrade()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Discussed internally, removed copystructure instead.

// roll back keys, but better safe than sorry and this doesn't happen
// enough to worry about the speed tradeoff.
priorArchiveVersion := p.ArchiveVersion
priorKeys := keyEntryMap(nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

FMI, is there a difference between this and var priorKeys keyEntryMap?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll convert to the other way to be a bit more canonical.

priorLatestVersion := p.LatestVersion
priorMinDecryptionVersion := p.MinDecryptionVersion
priorConvergentVersion := p.ConvergentVersion
priorKeys, err := copystructure.Copy(p.Keys)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason for using copystructure here vs doing a manual copy like in the Persist() and Rotate() functions? The only difference I see is that of the nil check on p.Keys.

Copy link
Contributor

@vishalnayak vishalnayak left a comment

Choose a reason for hiding this comment

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

LGTM!

@jefferai jefferai merged commit 3ce120e into master Feb 12, 2018
@jefferai jefferai deleted the transit-storage-error-txn branch February 12, 2018 22:27
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