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

   ### Why
   
   - #74690 let a Java task see when Airflow asks it to stop. #75421 reverted 
it because the K8s Lang-SDK test (`test_lang_sdk_mixed_language`) started to 
hang. A Java task sent its first request to the supervisor and then stopped 
logging.
   - #74690 added `@Synchronized` to `LogSender.configure` and 
`LogSender.send`. `LogSender` writes each log line with `runBlocking`. While 
`runBlocking` waits, it also runs other coroutines that are ready on the 
calling thread.
   - When the log connection opens, `configure` writes the messages that were 
logged before the connection opened. If the startup details arrive during that 
write, `configure` can run the task while it holds the `LogSender` lock. The 
task sends its first request. The thread that reads replies then blocks on the 
lock when it tries to log `Received` at debug level for the reply. As a result, 
the task waits for the reply forever.
   
   ### How
   
   - `LogSender` keeps its lock, but a separate thread writes each line while 
the caller waits with `Future.get()`. A thread that waits in `Future.get()` 
runs no coroutines, so a caller that holds the lock cannot run the task.
   - A caller that is already interrupted still gets its line written and keeps 
its interrupt status, as it did with `runBlocking`. On its own, `Future.get()` 
would throw `InterruptedException` at once for such a caller.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, 
please
   change below checkbox to `[X]` followed by the name of the tool, uncomment 
the "Generated-by".
   -->
   
   - [X] Yes - Claude Code
   
   <!--
   Generated-by: [Tool Name] 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