ajitgupta7 opened a new issue, #58949:
URL: https://github.com/apache/airflow/issues/58949

   ### Apache Airflow version
   
   3.1.3
   
   ### If "Other Airflow 2/3 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   
   ### Apache Airflow version3.0.0 / 3.1.0
   ### What happened: The scheduler crashes in a restart loop when trying to 
prune deadlines for DAG runs that are still running.
   ### Error
   File "/usr/local/lib/python3.12/site-packages/airflow/models/deadline.py", 
line 169, in prune_deadlines
   if dagrun.end_date <= deadline.deadline_time:
   TypeError: '<=' not supported between instances of 'NoneType' and 
'datetime.datetime'
   
   
   ### What you think should happen instead?
   
   The scheduler should handle running DAG runs (where `end_date` is `None`) 
gracefully without crashing.
   
   ### Suggested Fix
   Either add a null check:
   if dagrun.end_date and dagrun.end_date <= deadline.deadline_time:Or filter 
out running DAGs in the query (line ~156):
   select(Deadline, DagRun).join(DagRun).where(
       and_(*filter_conditions, DagRun.end_date.isnot(None))
   )### Operating System
   macOS / Linux
   
   
   ### How to reproduce
   
   1. Create a DAG with `deadline=DeadlineAlert(...)`
   2. Trigger the DAG
   3. While the DAG is running (`state='running'`, `end_date=NULL`), the 
scheduler will crash
   
   ### Operating System
   
   macOS / Linux
   
   ### Versions of Apache Airflow Providers
   
   N/A - core Airflow issue
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   _No response_
   
   ### Anything else?
   
   ### Suggested Fix
   Either add a null check:
   if dagrun.end_date and dagrun.end_date <= deadline.deadline_time:Or filter 
out running DAGs in the query (line ~156):
   select(Deadline, DagRun).join(DagRun).where(
       and_(*filter_conditions, DagRun.end_date.isnot(None))
   )### Operating System
   macOS / Linux
   
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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