Skip to content

Commit

Permalink
Avoid deadlocks on Santa target upserts
Browse files Browse the repository at this point in the history
  • Loading branch information
np5 committed Sep 4, 2024
1 parent 308b00b commit 151c483
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions zentral/contrib/santa/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ def update_or_create_targets(configuration, targets):
with connection.cursor() as cursor:
result = psycopg2.extras.execute_values(
cursor, query,
((target_type, target_identifier, configuration.id,
sorted(
(target_type, target_identifier, configuration.id,
val["blocked_incr"], val["collected_incr"], val["executed_incr"],
datetime.utcnow())
for (target_type, target_identifier), val in targets.items()),
for (target_type, target_identifier), val in targets.items()
),
fetch=True
)
columns = [c.name for c in cursor.description]
Expand Down

0 comments on commit 151c483

Please sign in to comment.