@@ -79,15 +79,25 @@ def get_lock_names_on_object_mutation(node: Node, branch: Branch, schema_branch:
79
79
Lock names include kind, some generic kinds, and values of attributes of corresponding uniqueness constraints.
80
80
"""
81
81
82
- lock_names = []
83
- # Check if node is using resource manager allocation
82
+ lock_names : list [str ] = []
83
+
84
+ def _add_pool_lock (pool_id : str ) -> None :
85
+ lock_name = f"resource_pool.{ pool_id } "
86
+ if lock_name not in lock_names :
87
+ lock_names .append (lock_name )
88
+
89
+ # Check if node is using resource manager allocation via attributes
90
+ for attr_name in getattr (node , "_attributes" , []):
91
+ attribute = getattr (node , attr_name , None )
92
+ if attribute is not None and getattr (attribute , "from_pool" , None ) and "id" in attribute .from_pool :
93
+ _add_pool_lock (attribute .from_pool ["id" ])
94
+
95
+ # Check if relationships allocate resources
84
96
for rel_name in node ._relationships :
85
97
rel_manager : RelationshipManager = getattr (node , rel_name )
86
98
for rel in rel_manager ._relationships :
87
99
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()
100
+ _add_pool_lock (rel .from_pool ["id" ])
91
101
92
102
if not branch .is_default and not _should_kind_be_locked_on_any_branch (node .get_kind (), schema_branch ):
93
103
return lock_names
@@ -99,7 +109,7 @@ def get_lock_names_on_object_mutation(node: Node, branch: Branch, schema_branch:
99
109
if ucs is None :
100
110
continue
101
111
102
- ucs_lock_names = []
112
+ ucs_lock_names : list [ str ] = []
103
113
uc_attributes_names = set ()
104
114
105
115
for uc in ucs :
0 commit comments