Skip to content

Commit ddada43

Browse files
arnaudsjsinmantaci
authored andcommitted
Fix bug where a cascading delete of an environment causes a deadlock because it acquires a table-level lock on an incorrect database table. (Issue #4834, PR #4863)
# Description Fix bug where lock is acquired on the ConfigurationModel table instead of the ResourceAction table. This bug causes deadlocks. closes #4834 # Self Check: - [x] Attached issue to pull request - [x] Changelog entry - [x] Type annotations are present - [x] Code is clear and sufficiently documented - [x] No (preventable) type errors (check using make mypy or make mypy-diff) - [x] Sufficient test cases (reproduces the bug/tests the requested feature) - [x] Correct, in line with design - [ ] ~~End user documentation is included or an issue is created for end-user documentation~~ # Reviewer Checklist: - [ ] Sufficient test cases (reproduces the bug/tests the requested feature) - [ ] Code is clear and sufficiently documented - [ ] Correct, in line with design
1 parent 19bac9e commit ddada43

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
description: Fix bug where a cascading delete of an environment causes a deadlock because it acquires a table-level lock on an incorrect database table.
3+
issue-nr: 4834
4+
issue-repo: inmanta-core
5+
change-type: patch
6+
destination-branches: [master, iso5]

src/inmanta/data/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5573,7 +5573,7 @@ async def delete_cascade(self) -> None:
55735573
await Code.delete_all(connection=con, environment=self.environment, version=self.version)
55745574

55755575
# Acquire explicit lock to avoid deadlock. See ConfigurationModel docstring
5576-
await self.lock_table(TableLockMode.SHARE, connection=con)
5576+
await ResourceAction.lock_table(TableLockMode.SHARE, connection=con)
55775577
await Resource.delete_all(connection=con, environment=self.environment, model=self.version)
55785578

55795579
# Delete facts when the resources in this version are the only

0 commit comments

Comments
 (0)