[WEB-4484]chore: streamline issue saving process with advisory locks for sequence management #7395

This commit is contained in:
Nikhil 2025-07-11 21:18:31 +05:30 committed by GitHub
parent 4501e44702
commit 71cd36865b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -216,7 +216,7 @@ class Issue(ProjectBaseModel):
with connection.cursor() as cursor:
# Get an exclusive lock using the project ID as the lock key
cursor.execute("SELECT pg_advisory_xact_lock(%s)", [lock_key])
try:
# Get the last sequence for the project
last_sequence = IssueSequence.objects.filter(
project=self.project
@ -225,7 +225,9 @@ class Issue(ProjectBaseModel):
# Strip the html tags using html parser
self.description_stripped = (
None
if (self.description_html == "" or self.description_html is None)
if (
self.description_html == "" or self.description_html is None
)
else strip_tags(self.description_html)
)
largest_sort_order = Issue.objects.filter(
@ -239,6 +241,10 @@ class Issue(ProjectBaseModel):
IssueSequence.objects.create(
issue=self, sequence=self.sequence_id, project=self.project
)
finally:
# Release the lock
with connection.cursor() as cursor:
cursor.execute("SELECT pg_advisory_unlock(%s)", [lock_key])
else:
# Strip the html tags using html parser
self.description_stripped = (