tosheer commented on issue #38826:
URL: https://github.com/apache/airflow/issues/38826#issuecomment-2045696944

   @Lee-W I have checked event when DAGs are deleted/ disabled its entry from 
`dag_schedule_dataset_reference` is not deleted which lead to addition of entry 
in `dataset_dag_run_queue` when an event is received. On event consumer side no 
check is in place it just check and provide all the events from the last run.
   
   For more details see 
https://github.com/apache/airflow/blob/main/airflow/jobs/scheduler_job_runner.py#L1260-L1274.
   
   @uranusjr do you think its a reasonable fix for the consumption path
   ` dataset_event_filters.append(DatasetEvent.timestamp > 
DagScheduleDatasetReference.created_at)`
   
   ```
                   dataset_event_filters = [
                       DagScheduleDatasetReference.dag_id == dag.dag_id,
                       DatasetEvent.timestamp <= exec_date,
                   ]
                   if previous_dag_run:
                       dataset_event_filters.append(DatasetEvent.timestamp > 
DagScheduleDatasetReference.execution_date)
                   else:
                       dataset_event_filters.append(DatasetEvent.timestamp > 
DagScheduleDatasetReference.created_at)
   
                   dataset_events = session.scalars(
                       select(DatasetEvent)
                       .join(
                           DagScheduleDatasetReference,
                           DatasetEvent.dataset_id == 
DagScheduleDatasetReference.dataset_id,
                       )
                       .where(*dataset_event_filters)
                   ).all()
   ```
   
   ```


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