Skip to content

Conditional Dataset(Asset) Updates Are Grouped Together Instead of Creating Distinct DAG Runs #53896

Closed

Description

@jfallt

Apache Airflow version

Other Airflow 2 version (please specify below)

If "Other Airflow 2 version" selected, which one?

2.10.5

What happened?

I have a DAG with conditional dataset scheduling.
Image

Instead of creating a dag run per dataset update, sometimes airflow will group the events together (if they occur close enough)
Image

What you think should happen instead?

I think there should be a distinct dag run per dataset update

How to reproduce

Create a DAG with conditional scheduling

Create 2 dataset events at the same time that are consumed by the dag we created

Operating System

linux

Versions of Apache Airflow Providers

No response

Deployment

Other Docker-based deployment

Deployment details

No response

Anything else?

Anytime there are dataset updates that happen at the same time or very close together

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. added
    kind:bug
    needs-triage
    on Jul 29, 2025
  2. shreyaskj-0710 commented on Aug 4, 2025

    @shreyaskj-0710
    Contributor

    I’ll work on this issue—let me know if it’s already been picked up by someone else.

  3. shreyaskj-0710 commented on Aug 5, 2025

    @shreyaskj-0710
    Contributor

    Hi @jfallt ,

    I was able to replicate the issue and come up with solution.

    Please refer the below content -

    Issue Analysis

    {
    "any": [
    "aladdin_adx_coupon",
    "aladdin_adx_factor",
    "aladdin_adx_issuer",
    "aladdin_adx_security",
    "aladdin_adx_shares_outstanding"
    ]
    }

    Suppose a Dag depends on multiple datasets aladdin_adx_coupon, aladdin_adx_factor ,aladdin_adx_issuer, aladdin_adx_security, aladdin_adx_shares_outstanding

    Then the schedule property of that DAG will be as below -

    schedule = aladdin_adx_coupon | aladdin_adx_factor | aladdin_adx_issuer | aladdin_adx_security | aladdin_adx_shares_outstanding

    Suppose multiple datasets gets updated at the same time then this OR condition of schedule property will be evaluated as True and the DAG will be triggered only once, not multiple times ( Individual DAG run per each update)

    Solution

    1] Should use TriggerDagRunOperator in each of the DAG’s which are updating the datasets.

    Eg code snippet -

    trigger_consumer = TriggerDagRunOperator(
    task_id="trigger_consumer_from_producer_a",
    trigger_dag_id="consumer_triggered_dag", # ID of the consumer DAG
    conf={
    "source_producer": "producer_dag_trigger_a",
    "producer_run_id": "{{ run_id }}",
    "logical_date": "{{ logical_date.isoformat() }}",
    "data_source_info": "Sales data batch A"
    },
    wait_for_completion=False,
    )

    2] In the sequential dependency chain make trigger_consumer as the final downstream task

    trigger_consumer

    3] And in the DAG which depends on datasets, below prop values should be implemented -

    with DAG(
    dag_id="consumer_triggered_dag", # IMPORTANT: This ID must match trigger_dag_id in producers
    start_date=pendulum.datetime(2025, 1, 1, 0, 0, 0, tz="Asia/Kolkata"),
    schedule=None, # Crucial: This DAG will ONLY run when explicitly triggered by TriggerDagRunOperator
    catchup=False,
    tags=["consumer", "direct_trigger"],
    ) as consumer_dag:

    Could you also please share your specific use case where it's necessary for the dependent DAG to trigger individually for each dataset update, instead of a single run based on any dataset change? Understanding this will help validate the proposed solution or explore alternatives.

  4. jfallt commented on Aug 6, 2025

    @jfallt
    ContributorAuthor

    I guess that technically fixes the issue but that doesn't explain why the dataset updates are grouped together in the first place.

    In this example this one DAG will process different files depending on which dataset uri is updated

  5. shreyaskj-0710 commented on Aug 7, 2025

    @shreyaskj-0710
    Contributor

    Hi @jfallt ,

    1] Reason why the dataset updates appear to be grouped is as follows -

    Suppose a Dag depends on multiple datasets aladdin_adx_coupon, aladdin_adx_factor ,aladdin_adx_issuer, aladdin_adx_security, aladdin_adx_shares_outstanding

    Then the schedule property of that DAG will be as below -

    schedule = aladdin_adx_coupon | aladdin_adx_factor | aladdin_adx_issuer | aladdin_adx_security | aladdin_adx_shares_outstanding

    Even if many datasets are updated at the same time, DAG will be triggered just once, because the rule is:
    "At any given time, if one or more of them update, go once!!"

    It doesn’t matter how many changed at the same time— one or five — it only causes a single run .

    Optional analogy:
    Think of it like a doorbell connected to 5 buttons — pressing any one or more buttons at the same time will ring the bell just once.

    That's why it appears to be grouped.

    2]One DAG will process different files depending on which dataset uri is updated

    You can pass the dataset info to the consumer dag (dag which consumes dataset) ,
    from the producer dag (dag which updates dataset) using the conf property of TriggerDagRunOperator in the producer dag -

    trigger_consumer = TriggerDagRunOperator(
    task_id="trigger_consumer_from_producer_a",
    trigger_dag_id="consumer_triggered_dag", # ID of the consumer DAG
    conf={
    "source_producer": "producer_dag_trigger_a",
    "producer_run_id": "{{ run_id }}",
    "logical_date": "{{ logical_date.isoformat() }}",
    "data_source_info": "dataset_name"
    },

    wait_for_completion=False,
    )

    the same conf value can be consumed by the consumer dag and perform required operations based on dataset.

    def _log_trigger_info(**context: Any):
    """
    details about how this DAG run was triggered,
    especially via the 'conf' passed by TriggerDagRunOperator.
    """
    dag_run = context["dag_run"]

    # Access the conf dictionary passed by the TriggerDagRunOperator
    triggered_by_conf = dag_run.conf
    
    if triggered_by_conf:
        print("\n--- Triggering Info from Producer DAG ---")
        print(f"  Source Producer: {triggered_by_conf.get('source_producer', 'N/A')}")
        print(f"  Producer Run ID: {triggered_by_conf.get('producer_run_id', 'N/A')}")
        print(f"  Producer Logical Date: {triggered_by_conf.get('logical_date', 'N/A')}")
    
        print(f"  Data Source Info: {triggered_by_conf.get('data_source_info', 'N/A')}") # dataset_name
        
        #perform required operation based on dataset
    
    else:
        print("\n--- No 'conf' data passed to this triggered run ---")
        print("(This likely means it was manually triggered without conf, or a time-based run)")
    
    print("Consumer: Starting data processing based on received trigger info...")
    
  6. jfallt commented on Aug 11, 2025

    @jfallt
    ContributorAuthor

    I'm pretty sure the issue stems from how the scheduler is handling asset/dataset changes

    https://github.com/apache/airflow/blob/8ef0ac3e473efb0c36fdecae5fe5b73fbdc186d4/airflow-core/src/airflow/assets/manager.py#L109C9-L109C30

    I'll have to set up some tests to validate my theory

  7. jroachgolf84 commented on Sep 16, 2026

    @jroachgolf84
    Collaborator

    There is some pretty active conversation going on in the Dev List about this (and it extends outside of conditional Asset scheduling).

  8. removed
    needs-triage
    on Sep 16, 2026
  9. linked a pull request that will close this issueMake asset event batching opt-in #68517on Nov 6, 2026
  10. shahar1 commented on Nov 6, 2026

    @shahar1
    Contributor

    Closing as the original issue has been reported for v2.10, and #68517 seems to handle it in v3.
    If more fine-tuning is needed for this feature, please create a new GitHub issue / dev list discussion / PR, or any combination of those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    _eol_affected_version:2.10area:corekind:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions