Skip to content

Commit 80f493f

Browse files
committed
Revert "fix: make sure to lock on resource manager allocations"
BROKEN: this does not handle double lock/deadlock issues when we acquire a resource pool lock in run_constraints_and_save() and then in get_resource(). We probably require a mechanism to check if the lock is actually held by the current worker, if so it can proceed without acquiring the lock. This reverts commit 31d7940.
1 parent 31d7940 commit 80f493f

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

backend/infrahub/lock_getter.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import hashlib
2-
from typing import TYPE_CHECKING
32

43
from infrahub.core.branch import Branch
54
from infrahub.core.constants import InfrahubKind
@@ -8,9 +7,6 @@
87
from infrahub.core.schema.schema_branch import SchemaBranch
98
from infrahub.lock import build_object_lock_name
109

11-
if TYPE_CHECKING:
12-
from infrahub.core.relationship import RelationshipManager
13-
1410
KINDS_CONCURRENT_MUTATIONS_NOT_ALLOWED = [InfrahubKind.GENERICGROUP]
1511

1612

@@ -79,20 +75,11 @@ def get_lock_names_on_object_mutation(node: Node, branch: Branch, schema_branch:
7975
Lock names include kind, some generic kinds, and values of attributes of corresponding uniqueness constraints.
8076
"""
8177

82-
lock_names = []
83-
# Check if node is using resource manager allocation
84-
for rel_name in node._relationships:
85-
rel_manager: RelationshipManager = getattr(node, rel_name)
86-
for rel in rel_manager._relationships:
87-
if rel.from_pool and "id" in rel.from_pool:
88-
lock_names.append(
89-
f"resource_pool.{rel.from_pool['id']}"
90-
) # lock on resource manager using the same lock we have in get_resource()
91-
9278
if not branch.is_default and not _should_kind_be_locked_on_any_branch(node.get_kind(), schema_branch):
93-
return lock_names
79+
return []
9480

9581
lock_kinds = _get_kinds_to_lock_on_object_mutation(node.get_kind(), schema_branch)
82+
lock_names = []
9683
for kind in lock_kinds:
9784
schema = schema_branch.get(name=kind)
9885
ucs = schema.uniqueness_constraints

0 commit comments

Comments
 (0)