From bac0b9755e7bf963adef86ddb32482ce1d0a9754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Fri, 22 Feb 2019 15:37:42 +0100 Subject: [PATCH] Improved concurrency check on cache assignation --- server/src/uds/core/managers/UserServiceManager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/uds/core/managers/UserServiceManager.py b/server/src/uds/core/managers/UserServiceManager.py index f812cda95..3504e05c2 100644 --- a/server/src/uds/core/managers/UserServiceManager.py +++ b/server/src/uds/core/managers/UserServiceManager.py @@ -270,7 +270,7 @@ class UserServiceManager(object): if len(cache) != 0: cache = cache[0] # Ensure element is reserved correctly on DB - if ds.cachedUserServices().select_for_update().filter(uuid=cache.uuid).update(user=user, cache_level=0) != 1: + if ds.cachedUserServices().select_for_update().filter(user=None, uuid=cache.uuid).update(user=user, cache_level=0) != 1: cache = None else: cache = None @@ -280,7 +280,7 @@ class UserServiceManager(object): cache = ds.cachedUserServices().select_for_update().filter(cache_level=services.UserDeployment.L1_CACHE, state=State.USABLE)[:1] if len(cache) > 0: cache = cache[0] - if ds.cachedUserServices().select_for_update().filter(uuid=cache.uuid).update(user=user, cache_level=0) != 1: + if ds.cachedUserServices().select_for_update().filter(user=None, uuid=cache.uuid).update(user=user, cache_level=0) != 1: cache = None else: cache = None @@ -306,7 +306,7 @@ class UserServiceManager(object): cache = ds.cachedUserServices().select_for_update().filter(cache_level=services.UserDeployment.L1_CACHE, state=State.PREPARING)[:1] if len(cache) > 0: cache = cache[0] - if ds.cachedUserServices().select_for_update().filter(uuid=cache.uuid).update(user=user, cache_level=0) != 1: + if ds.cachedUserServices().select_for_update().filter(user=None, uuid=cache.uuid).update(user=user, cache_level=0) != 1: cache = None else: cache.assignToUser(user)