Airflow Xcom — Exclusive
Airflow XCom: The Complete Guide to Cross-Task Communication
not natively support exclusive access
Airflow XCom does across tasks. The default behavior allows concurrent writes and reads, leading to race conditions and data corruption in dynamic DAGs. airflow xcom exclusive
task2 = BashOperator( task_id='task2', bash_command='echo task_instance.xcom_pull("greeting") ', dag=dag, ) Airflow XCom: The Complete Guide to Cross-Task Communication
- Exclusive write – Only one task can push to a given key.
- Exclusive read – Only one consumer task can pull a given key.
- Key namespacing – Logical isolation via task_id + key.
- XCom backend with locking – Database-level or Redis-based locks.
@task def extract(): return "user_ids": [1,2,3], "source": "api" Exclusive write – Only one task can push to a given key
def pull_task(**context): value = context['ti'].xcom_pull(key='my_key', task_ids='push_task')