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 signalling Wait in regulator.enter #2299

Merged
merged 1 commit into from
Jun 23, 2017

Conversation

dmage
Copy link
Contributor

@dmage dmage commented Jun 2, 2017

In some conditions, regulator.exit may not send a signal to blocked
regulator.enter.

Let's assume we are in the critical section of regulator.exit and r.available
is equal to 0. And there are three more gorotines. One goroutine also executes
regulator.exit and waits for the lock. Rest run regulator.enter and wait for
the signal.

We send the signal, and after releasing the lock, there will be lock
contention:

  1. Wait from regulator.enter
  2. Lock from regulator.exit

If the winner is Lock from regulator.exit, we will not send another signal to
unlock the second Wait.

@GordonTheTurtle
Copy link

Please sign your commits following these rules:
https://github.com/moby/moby/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "regulator" git@github.com:dmage/distribution.git somewhere
$ cd somewhere
$ git commit --amend -s --no-edit
$ git push -f

Amending updates the existing PR. You DO NOT need to open a new one.

In some conditions, regulator.exit may not send a signal to blocked
regulator.enter.

Let's assume we are in the critical section of regulator.exit and r.available
is equal to 0. And there are three more gorotines. One goroutine also executes
regulator.exit and waits for the lock. Rest run regulator.enter and wait for
the signal.

We send the signal, and after releasing the lock, there will be lock
contention:

  1. Wait from regulator.enter
  2. Lock from regulator.exit

If the winner is Lock from regulator.exit, we will not send another signal to
unlock the second Wait.

Signed-off-by: Oleg Bulatov <obulatov@redhat.com>
@codecov
Copy link

codecov bot commented Jun 2, 2017

Codecov Report

Merging #2299 into master will decrease coverage by 10.04%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #2299       +/-   ##
===========================================
- Coverage   61.57%   51.53%   -10.05%     
===========================================
  Files         125      125               
  Lines       11397    11396        -1     
===========================================
- Hits         7018     5873     -1145     
- Misses       3493     4779     +1286     
+ Partials      886      744      -142
Impacted Files Coverage Δ
registry/storage/driver/base/regulator.go 100% <100%> (+7.01%) ⬆️
registry/storage/driver/gcs/gcs.go 0.4% <0%> (-68.94%) ⬇️
registry/storage/driver/oss/oss.go 0.56% <0%> (-57.23%) ⬇️
registry/storage/driver/s3-aws/s3.go 4.57% <0%> (-56.23%) ⬇️
registry/storage/driver/s3-goamz/s3.go 0.5% <0%> (-51.4%) ⬇️
registry/client/transport/transport.go 69.69% <0%> (-9.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e2f10e...258345b. Read the comment docs.

@miminar
Copy link
Contributor

miminar commented Jun 12, 2017

LGTM, we've been hit by this in performance testing on GlusterFS.

@aaronlehmann
Copy link
Contributor

LGTM

@aaronlehmann aaronlehmann merged commit caa175c into distribution:master Jun 23, 2017
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