From 96bd35bfb4ced83cdd8b9399f39d72a97a14a416 Mon Sep 17 00:00:00 2001 From: Dirk Julich Date: Fri, 20 Mar 2026 17:58:59 +0100 Subject: [PATCH] AAP-57614 fix: also write installed_collections directly to DB save_indirect_host_entries calls fetch_job_event_query which reads job.installed_collections from the DB. When dispatched from artifacts_handler, installed_collections was still only in delay_update (not yet flushed to DB), so the task found no matching EventQuery records and created no IndirectManagedNodeAudit entries. Write both event_queries_processed and installed_collections directly to the DB before dispatching, so save_indirect_host_entries has all the data it needs immediately. Co-Authored-By: Claude Opus 4.6 --- awx/main/tasks/callback.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/awx/main/tasks/callback.py b/awx/main/tasks/callback.py index 72ee37cbd8..48a4d10e5c 100644 --- a/awx/main/tasks/callback.py +++ b/awx/main/tasks/callback.py @@ -301,14 +301,19 @@ class RunnerCallback: else: logger.warning(f'The file {COLLECTION_FILENAME} unexpectedly did not contain ansible_version') - # Write event_queries_processed=False directly to the DB rather - # than using delay_update, because delay_update only writes when - # the final job status is saved. save_indirect_host_entries - # checks this column under select_for_update and would bail out - # if it still saw the default (True). + # Write event_queries_processed and installed_collections directly + # to the DB rather than using delay_update alone. delay_update + # only writes when the final job status is saved, but + # save_indirect_host_entries needs both values in the DB + # immediately: event_queries_processed=False to pass the + # select_for_update gate, and installed_collections to find + # matching EventQuery records via fetch_job_event_query. from awx.main.models import Job - Job.objects.filter(id=self.instance.id).update(event_queries_processed=False) + db_updates = {'event_queries_processed': False} + if 'installed_collections' in query_file_contents: + db_updates['installed_collections'] = query_file_contents['installed_collections'] + Job.objects.filter(id=self.instance.id).update(**db_updates) # Dispatch save_indirect_host_entries to process the EventQuery # records created above. handle_success_and_failure_notifications