diff --git a/awx/main/models/events.py b/awx/main/models/events.py index fcbb81409a..00c5983704 100644 --- a/awx/main/models/events.py +++ b/awx/main/models/events.py @@ -602,7 +602,7 @@ class JobEvent(BasePlaybookEvent): h.last_job_host_summary_id = host_mapping[h.id] updated_hosts.add(h) - Host.objects.bulk_update(list(updated_hosts), ['last_job_id', 'last_job_host_summary_id'], batch_size=100) + Host.objects.bulk_update(sorted(updated_hosts, key=lambda host: host.id), ['last_job_id', 'last_job_host_summary_id'], batch_size=100) # Create/update Host Metrics self._update_host_metrics(updated_hosts_list) diff --git a/awx/main/tasks/facts.py b/awx/main/tasks/facts.py index 8e52c1eb79..eb8cdf185c 100644 --- a/awx/main/tasks/facts.py +++ b/awx/main/tasks/facts.py @@ -62,7 +62,8 @@ def start_fact_cache(hosts, destination, log_data, timeout=None, inventory_id=No def raw_update_hosts(host_list): - Host.objects.bulk_update(host_list, ['ansible_facts', 'ansible_facts_modified']) + host_list = sorted(host_list, key=lambda host: host.id) + Host.objects.bulk_update(host_list, ['ansible_facts', 'ansible_facts_modified'], batch_size=100) def update_hosts(host_list, max_tries=5):