Skip to content

Commit

Permalink
Merge pull request #18080 from ironcladlou/kube-58107
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue (batch tested with PRs 17976, 17195, 18093, 18080, 17922).

UPSTREAM: 58107: Fix quota controller worker deadlock

The resource quota controller worker pool can deadlock when:

* Worker goroutines are idle waiting for work from queues
* The Sync() method detects discovery updates to apply

The problem is workers acquire a read lock while idle, making write lock
acquisition dependent upon the presence of work in the queues.

The Sync() method blocks on a pending write lock acquisition and won't unblock
until every existing worker processes one item from their queue and releases
their read lock. While the Sync() method's lock is pending, all new read lock
acquisitions will block; if a worker does process work and release its lock, it
will then become blocked on a read lock acquisition; they become blocked on
Sync(). This can easily deadlock all the workers processing from one queue while
any workers on the other queue remain blocked waiting for work.

Fix the deadlock by refactoring workers to acquire a read lock *after* work is
popped from the queue. This allows writers to get locks while workers are idle,
while preserving the worker pause semantics necessary to allow safe sync.
  • Loading branch information
openshift-merge-robot authored Jan 16, 2018
2 parents 1cc7d74 + 10828c9 commit 3a20d59
Showing 1 changed file with 2 additions and 4 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3a20d59

Please sign in to comment.