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

Remove locking from layer store creation #493

Merged
merged 1 commit into from
Jan 31, 2020
Merged

Remove locking from layer store creation #493

merged 1 commit into from
Jan 31, 2020

Conversation

saschagrunert
Copy link
Member

The layerstore.Load() on new[RO]LayerStore required a held lock on
store initialization. Since the consumers of the layer storage already
call Load(), it should not be necessary to lock on initialization of
the layer store.

@saschagrunert
Copy link
Member Author

Let's see if this works...

@saschagrunert
Copy link
Member Author

Ready for review, PTAL

layers.go Outdated Show resolved Hide resolved
@vrothberg
Copy link
Member

Thanks a lot, @saschagrunert!

Would you mind opening test PRs for Skopeo, Buildah, Podman and CRI-O vendoring this branch? This will help us gain confidence in the change and make sure we didn't miss any potential side effect.

@saschagrunert
Copy link
Member Author

Thanks a lot, @saschagrunert!

Would you mind opening test PRs for Skopeo, Buildah, Podman and CRI-O vendoring this branch? This will help us gain confidence in the change and make sure we didn't miss any potential side effect.

Yep sure, see the linked PRs. Let's see what the tests say.

@rhatdan
Copy link
Member

rhatdan commented Jan 6, 2020

@saschagrunert Looks like something went wrong with your rebase push?

@saschagrunert
Copy link
Member Author

Yes, thanks for the hint. I'll have to check if the podman test failures in containers/podman#4696 are caused by this PR. 🤔

@saschagrunert
Copy link
Member Author

Looks like we have something which finally works. I will check it out with libpod

@saschagrunert
Copy link
Member Author

saschagrunert commented Jan 24, 2020

Ready for review PTAL @vrothberg @rhatdan @nalind
PS: containers/podman#4696 looks green as well.

@TomSweeneyRedHat
Copy link
Member

@saschagrunert could you rebase the other project just to double check those too?

@saschagrunert
Copy link
Member Author

Copy link
Member

@rhatdan rhatdan left a comment

Choose a reason for hiding this comment

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

LGTM
But I want @nalind and @vrothberg to approve.

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Only minor nits. Please squash the commits into one before merging. Other than that, LGTM.

@nalind WDYT?

layers.go Outdated
if conflict, ok := names[name]; ok {
r.removeName(conflict, name)
shouldSave = true
if r.Locked() {
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment why this only applies when the store is locked.

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably not needed, I will give a removal of this part another try.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like it is working, I'm now vendoring it into the related PRs.

layers.go Outdated Show resolved Hide resolved
layers.go Outdated Show resolved Hide resolved
@rhatdan
Copy link
Member

rhatdan commented Jan 28, 2020

Worked on Buildah, skopeo, libpod, CRI-O. This looks good.

@@ -2788,6 +2788,9 @@ func (s *store) Layers() ([]Layer, error) {
if err != nil {
return nil, err
}
if err := lstore.LoadLocked(); err != nil {
return nil, err
}
Copy link
Member

Choose a reason for hiding this comment

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

This unconditionally reloads the store contents using a write lock here, in addition to where it's conditionally done under a read lock on line 2805. We'll probably want to drop lstore from the initial value of the slice that's constructed on line 2800 to avoid that extra bit of work.

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright I put another commit on top of my changes to see if the new logic breaks anything.

@nalind
Copy link
Member

nalind commented Jan 29, 2020

I think there's a bit of work we can drop from Layers(), otherwise looks fine.

The `layerstore.Load()` on `new[RO]LayerStore` required a held lock on
store initialization. Since the consumers of the layer storage already
call `Load()`, it should not be necessary to lock on initialization of
the layer store.

Signed-off-by: Sascha Grunert <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented Jan 31, 2020

LGTM

@rhatdan rhatdan merged commit f9ce88b into containers:master Jan 31, 2020
@saschagrunert saschagrunert deleted the layer-store-load-lock branch January 31, 2020 07:42
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.

6 participants