!!exclusive!! - Airflow Xcom Exclusive
Airflow XCom and Exclusive Access: A Comprehensive Guide
Troubleshooting checklist
- Unexpected missing XCom: confirm execution_date/run_id and task_id match; check producer succeeded.
- Stale/overwritten XCom: check for multiple writers (same task_id retries, or different tasks accidentally using same task_id due to dynamic task mapping).
- Large or failing XCom serialization: check XCom backend limits and serialization errors in worker logs.
Task C sees the last written value (non-deterministic)
Pattern A: The Return Value (The Simplest Exclusive)
Airflow automatically pushes a task’s return value as an XCom with key return_value. For exclusivity, return only a primitive or a small dictionary. airflow xcom exclusive
def extract_api_data(**context): # Fetch data and write to temporary location temp_table = f"temp_data_context['ds_nodash']" write_to_bigquery(temp_table) return temp_table # Single string: the exclusive reference
def transform_data(table_name, **context): # table_name pulled via task_id='extract_api_data' result_table = aggregate_in_bigquery(table_name) return result_tableAirflow XCom and Exclusive Access: A Comprehensive Guide