jason810496 commented on code in PR #50715:
URL: https://github.com/apache/airflow/pull/50715#discussion_r2103906545


##########
airflow-core/src/airflow/utils/log/log_reader.py:
##########
@@ -96,10 +99,17 @@ def read_log_stream(self, ti: TaskInstance, try_number: int 
| None, metadata: di
                 TaskInstanceState.RUNNING,
                 TaskInstanceState.DEFERRED,
             ):

Review Comment:
   **The `ti` object passed into `read_log_stream` will always reflect the same 
state**, because **SQLAlchemy doesn’t automatically reflect changes made to the 
underlying database by other processes**.
   
   Based on the previous scenario (see: 
https://github.com/apache/airflow/pull/50715/files#r2101658101 ),  if the `ti` 
is in the `RUNNING` state when it is initially passed into `read_log_stream`, 
it will remain `RUNNING` even if another process has updated its state.
   
   We should consider adding `session.refresh(ti)` to ensure we get the latest 
(and correct) state of the `ti` object, especially in cases where it may have 
transitioned to `SUCCESS` or `FAILED` after several calls to `read_log_chunks`.
   



-- 
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