The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6803

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
There is a race modifying the lock map with a new lock channel for a named lock which causes hangs during high load benchmarks.

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
From 311825ba29d8a6d9551004441e992653c3df0120 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@canonical.com>
Date: Wed, 29 Jan 2020 11:41:09 +0000
Subject: [PATCH] lxd/storgage/locking/lock: Fixes concurrent access race to
 map

There is a race modifying the lock map with a new lock channel for a named lock 
which causes hangs during high load benchmarks.

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
---
 lxd/storage/locking/lock.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lxd/storage/locking/lock.go b/lxd/storage/locking/lock.go
index bafdcecddb..727974484c 100644
--- a/lxd/storage/locking/lock.go
+++ b/lxd/storage/locking/lock.go
@@ -27,12 +27,12 @@ func Lock(poolName string, volType string, volName string) 
func() {
                // Get exclusive access to the map and see if there is already 
an operation ongoing.
                ongoingOperationMapLock.Lock()
                waitCh, ok := ongoingOperationMap[lockID]
-               ongoingOperationMapLock.Unlock()
 
                if !ok {
                        // No ongoing operation, create a new channel to 
indicate our new operation.
                        waitCh = make(chan struct{})
                        ongoingOperationMap[lockID] = waitCh
+                       ongoingOperationMapLock.Unlock()
 
                        // Return a function that will complete the operation.
                        return func() {
@@ -59,6 +59,7 @@ func Lock(poolName string, volType string, volName string) 
func() {
 
                // An existing operation is ongoing, lets wait for that to 
finish and then try
                // to get exlusive access to create a new operation again.
+               ongoingOperationMapLock.Unlock()
                <-waitCh
        }
 }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to