AAP-57614 fix: write event_queries_processed directly to DB

The previous commit dispatched save_indirect_host_entries from
artifacts_handler, but used delay_update to set event_queries_processed
to False. delay_update only queues the write for the final job status
save, so save_indirect_host_entries would read the default (True) from
the DB and bail out before processing.

Replace delay_update(event_queries_processed=False) with a direct
Job.objects.filter().update() call so the value is visible in the DB
before save_indirect_host_entries runs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dirk Julich
2026-03-20 17:28:10 +01:00
parent 53be3d16bd
commit 21e73cb065

View File

@@ -278,7 +278,6 @@ class RunnerCallback:
def artifacts_handler(self, artifact_dir): def artifacts_handler(self, artifact_dir):
success, query_file_contents = try_load_query_file(artifact_dir) success, query_file_contents = try_load_query_file(artifact_dir)
if success: if success:
self.delay_update(event_queries_processed=False)
collections_info = collect_queries(query_file_contents) collections_info = collect_queries(query_file_contents)
for collection, data in collections_info.items(): for collection, data in collections_info.items():
version = data['version'] version = data['version']
@@ -302,6 +301,15 @@ class RunnerCallback:
else: else:
logger.warning(f'The file {COLLECTION_FILENAME} unexpectedly did not contain ansible_version') 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).
from awx.main.models import Job
Job.objects.filter(id=self.instance.id).update(event_queries_processed=False)
# Dispatch save_indirect_host_entries to process the EventQuery # Dispatch save_indirect_host_entries to process the EventQuery
# records created above. handle_success_and_failure_notifications # records created above. handle_success_and_failure_notifications
# may have already run and skipped dispatching because # may have already run and skipped dispatching because