Skip to content
This repository was archived by the owner on Nov 19, 2026. It is now read-only.

lockfile: add RecursiveLock() API - #347

Merged
nalind merged 1 commit into
containers:masterfrom
vrothberg:recursive-locks
May 31, 2019
Merged

nalind merged 1 commit into
containers:masterfrom
vrothberg:recursive-locks

Conversation

@vrothberg

Copy link
Copy Markdown
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
Copy Markdown
Member Author

@nalind @rhatdan @giuseppe PTAL

I need it here.

@TomSweeneyRedHat

Copy link
Copy Markdown
Member

LGTM, but definitely want some other head nods.

Comment thread lockfile_unix.go Resolved
@vrothberg

Copy link
Copy Markdown
Member Author

@nalind @rhatdan are we good to go?

@vrothberg

Copy link
Copy Markdown
Member Author

@nalind @rhatdan ping

@rhatdan

rhatdan commented May 22, 2019

Copy link
Copy Markdown
Member

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

@nalind

nalind commented May 22, 2019

Copy link
Copy Markdown
Member

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
Copy Markdown
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]>

@vrothberg vrothberg left a comment

Copy link
Copy Markdown
Member Author

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.

Comment thread lockfile_test.go
}
}

func TestLockfileMixedConcurrentRecursiveWriters(t *testing.T) {

Copy link
Copy Markdown
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

rhatdan commented May 31, 2019

Copy link
Copy Markdown
Member

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

@nalind

nalind commented May 31, 2019

Copy link
Copy Markdown
Member

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants