dabla opened a new pull request, #77877:
URL: https://github.com/apache/airflow/pull/77877

   `TimeoutPosix.handle_timeout`, the `SIGALRM` handler behind a task's 
`execution_timeout`, logged "Process timed out" before it raised. Python runs a 
signal handler on the main thread, between two bytecodes of whatever that 
thread is doing. Writing a log line takes the lock of the log output, which is 
not reentrant. When the alarm arrived while the main thread was itself writing 
a log line, the handler waited for the lock its own thread held, so 
`AirflowTaskTimeout` was never raised and the task hung until the supervisor 
killed it.
   
   The handler now only raises. The line is logged by `__exit__`, after the 
timer is disarmed, once the exception has left the block and the locks taken 
inside it are released. The message and its `pid` are unchanged, and every user 
of `timeout()` keeps it (the task runner, the Dag file importer, the connection 
test).
   
   Tests:
   - the alarm is raised while the main thread holds a lock; the line must be 
logged once, and only after that lock is released. It fails on `main`, where 
the handler logs while the lock is held.
   - nothing is logged when the block ends in time.
   
   The reproduction script of the issue hangs on `main` and prints `raised: 
AirflowTaskTimeout` with this change.
   
   closes: #77875
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Fable 5.2)
   
   Generated-by: Claude Code (Fable 5.2) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to