The GitHub Actions job "Check newsfragment PR number" on airflow.git/fix/orphan-reset-loses-hostname-in-ti-history has failed. Run started by GitHub user nagasrisai (triggered by nagasrisai).
Head commit for run: a3f798986a63887e634a11c3efd317e4cdba793e / nagasrisai <[email protected]> fix: preserve hostname and start_date in task_instance_history on orphan reset When adopt_or_reset_orphaned_tasks() resets a task instance it calls prepare_db_for_next_try(), which in turn calls TaskInstanceHistory.record_ti() to archive the current attempt before issuing the next try. The query in adopt_or_reset_orphaned_tasks() uses load_only() with only seven columns (id, dag_id, task_id, run_id, map_index, state, external_executor_id), so hostname, start_date, end_date, and duration are deferred. When TaskInstanceHistory.__init__ iterates every column of the history table it triggers a separate lazy-SELECT round-trip for each deferred attribute, and any task whose pod was killed before the task-sdk could call the execution API would have hostname='' and start_date=None in the DB — values that end up verbatim in the history row. An empty-string hostname in task_instance_history causes FileTaskHandler to build the served-log URL as http://:8793/log/..., which Python's urllib rejects with "No host supplied" — the error visible in the UI for each earlier failed retry attempt. Changes ------- * scheduler_job_runner.py: add hostname, start_date, end_date, duration, and try_number to the load_only() clause in adopt_or_reset_orphaned_tasks() so all fields needed by record_ti() are fetched in the same query as the row-lock, eliminating the per-attribute lazy-SELECT round-trips. * taskinstancehistory.py: in TaskInstanceHistory.__init__, convert hostname=='' to None before storing in the history row. TaskInstance initialises hostname to "" (not None), so a task that never contacted the execution API leaves an empty string in the DB. Storing NULL instead lets callers distinguish 'hostname was never reported' from a real hostname, and prevents the http://:8793 log URL construction. Tests ----- * test_adopt_or_reset_resettable_tasks_preserves_execution_metadata_in_history: verifies that a task in RUNNING state with a real hostname has that hostname preserved in the history row after an orphan reset. * test_adopt_or_reset_resettable_tasks_stores_null_hostname_when_never_reported: verifies that a task whose hostname was never set (pod killed before task-sdk reported back) produces a history row with hostname=NULL rather than hostname=''. Report URL: https://github.com/apache/airflow/actions/runs/30979458244 With regards, GitHub Actions via GitBox --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
