mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
change host -> last_job_id bulk update query to avoid locking issues
see: https://github.com/ansible/awx/issues/8145
This commit is contained in:
parent
3184bccb33
commit
89ff8e1f3e
@ -520,13 +520,21 @@ class JobEvent(BasePlaybookEvent):
|
||||
(summary['host_id'], summary['id'])
|
||||
for summary in JobHostSummary.objects.filter(job_id=job.id).values('id', 'host_id')
|
||||
)
|
||||
updated_hosts = set()
|
||||
for h in all_hosts:
|
||||
# if the hostname *shows up* in the playbook_on_stats event
|
||||
if h.name in hostnames:
|
||||
h.last_job_id = job.id
|
||||
updated_hosts.add(h)
|
||||
if h.id in host_mapping:
|
||||
h.last_job_host_summary_id = host_mapping[h.id]
|
||||
Host.objects.bulk_update(all_hosts, ['last_job_id', 'last_job_host_summary_id'])
|
||||
updated_hosts.add(h)
|
||||
|
||||
Host.objects.bulk_update(
|
||||
list(updated_hosts),
|
||||
['last_job_id', 'last_job_host_summary_id'],
|
||||
batch_size=100
|
||||
)
|
||||
|
||||
|
||||
@property
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user