forked from TrueCloudLab/frostfs-qos
[#12] mclock: Fix deadlock caused by mclock.Close
Deadlock scenario: - mclock closed by `Close` method, it locks mutex and calls `clock.close` - clock starts `scheduleRequest` goroutine, it tries to lock mutex - `clock.Close` waits for all goroutines Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
346752477b
commit
1ca213ee7c
1 changed files with 7 additions and 3 deletions
|
@ -137,15 +137,15 @@ func (q *MClock) RequestArrival(ctx context.Context, tag string) (ReleaseFunc, e
|
|||
// No new requests for scheduling will be accepted after the closing.
|
||||
func (q *MClock) Close() {
|
||||
q.mtx.Lock()
|
||||
defer q.mtx.Unlock()
|
||||
|
||||
q.closed = true
|
||||
q.clock.close()
|
||||
for q.limitQueue.Len() > 0 {
|
||||
item := heap.Pop(q.limitQueue).(*limitMQueueItem)
|
||||
close(item.r.canceled)
|
||||
q.removeFromQueues(item.r)
|
||||
}
|
||||
q.mtx.Unlock()
|
||||
|
||||
q.clock.close()
|
||||
}
|
||||
|
||||
func validateParams(runLimit uint64, tagInfo map[string]TagInfo) error {
|
||||
|
@ -261,6 +261,10 @@ func (q *MClock) scheduleRequest() {
|
|||
q.mtx.Lock()
|
||||
defer q.mtx.Unlock()
|
||||
|
||||
if q.closed {
|
||||
return
|
||||
}
|
||||
|
||||
q.scheduleRequestUnsafe()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue