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

lockfile: add RecursiveLock() API #347

Merged
merged 1 commit into from
May 31, 2019

Conversation

vrothberg
Copy link
Member

Add a RecursiveLock() API to allow for recursive acquisitions of a
writer lock within the same process space. This is yet another
requirement for the copy-detection mechanism in containers/image where
multiple goroutines can be pulling the same blob. Having a recursive
lock avoids a complex synchronization mechanism as the commit order is
determinted by the corresponding index in the image.

Signed-off-by: Valentin Rothberg [email protected]

@vrothberg
Copy link
Member Author

@nalind @rhatdan @giuseppe PTAL

I need it here.

@TomSweeneyRedHat
Copy link
Member

LGTM, but definitely want some other head nods.

@vrothberg
Copy link
Member Author

@nalind @rhatdan are we good to go?

@vrothberg
Copy link
Member Author

@nalind @rhatdan ping

@rhatdan
Copy link
Member

rhatdan commented May 22, 2019

I am fine with this, but we need @nalind review.

@nalind
Copy link
Member

nalind commented May 22, 2019

Looks reasonable, but I'd like a test that ensures that mixing recursive and non-recursive write locks in a single process doesn't unexpectedly break.

@vrothberg
Copy link
Member Author

Great idea. I will update the PR and re-ping once the new tests are green.

Add a RecursiveLock() API to allow for recursive acquisitions of a
writer lock within the same process space.  This is yet another
requirement for the copy-detection mechanism in containers/image where
multiple goroutines can be pulling the same blob.  Having a recursive
lock avoids a complex synchronization mechanism as the commit order is
determinted by the corresponding index in the image.

Signed-off-by: Valentin Rothberg <[email protected]>
Copy link
Member Author

@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.

Test added, and CI is green. @nalind PTAL.

@@ -408,6 +498,63 @@ func TestLockfileMixedConcurrent(t *testing.T) {
}
}

func TestLockfileMixedConcurrentRecursiveWriters(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Here's the new test.

@rhatdan
Copy link
Member

rhatdan commented May 31, 2019

@nalind Can we merge this so we can create a new version?

@nalind
Copy link
Member

nalind commented May 31, 2019

LGTM

@nalind nalind merged commit d60a53b into containers:master May 31, 2019
@vrothberg vrothberg deleted the recursive-locks branch July 25, 2019 09:41
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.

4 participants