hwang-cadent commented on issue #58307:
URL: https://github.com/apache/airflow/issues/58307#issuecomment-3533399247

   It seems the query in _find_task_instances_without_heartbeats() doesn't 
handle NULL last_heartbeat_at values.
   
   see line 2479 in scheduler_job_runner.py
   
   .where(
       TI.state.in_((TaskInstanceState.RUNNING, TaskInstanceState.RESTARTING)),
       TI.last_heartbeat_at < limit_dttm,  #  This excludes NULL values!
   )
   
   When task_instance_heartbeat_sec = 0, tasks don't send heartbeats, so 
last_heartbeat_at is NULL. In SQL, NULL < anything evaluates to NULL (not 
True), so rows with NULL last_heartbeat_at are excluded from the WHERE 
clause.The query should include tasks where last_heartbeat_at is NULL OR older 
than the timeout. like 
   
   .where(
       TI.state.in_((TaskInstanceState.RUNNING, TaskInstanceState.RESTARTING)),
       or_(
           TI.last_heartbeat_at.is_(None),  # Handle NULL case
           TI.last_heartbeat_at < limit_dttm
       ),
   )


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