From 2ce5c81ca2e94155374962805b815f5e9820f813 Mon Sep 17 00:00:00 2001 From: Daniel Standish <15932138+dstandish@users.noreply.github.com> Date: Thu, 16 Jul 2026 11:00:37 -0700 Subject: [PATCH] Clarify AssetPartitionDagRun provisional-run docstring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous wording ("we should not allow more than one like this") did not state the actual invariant. Make explicit that rows are never deleted — so multiple records per target_dag_id/partition_key are expected — and that the constraint is specifically at most one row with a null created_dag_run_id, which the _lock_asset_model mutex enforces. --- airflow-core/src/airflow/models/asset.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/airflow-core/src/airflow/models/asset.py b/airflow-core/src/airflow/models/asset.py index 4354034e649fe..0788611d8a02d 100644 --- a/airflow-core/src/airflow/models/asset.py +++ b/airflow-core/src/airflow/models/asset.py @@ -913,9 +913,15 @@ class AssetPartitionDagRun(Base): We can look up the AssetEvents that contribute to AssetPartitionDagRun entities with the PartitionedAssetKeyLog mapping table. - Where dag_run_id is null, the dag run has not yet been created. - We should not allow more than one like this. But to guard against - an accident, we should always work on the latest one. + Rows are never deleted from this table, so multiple records with the same + target_dag_id / partition_key are expected in general; each dag run that + gets created leaves its APDR record behind. + + Where created_dag_run_id is null, the dag run has not yet been created. + We should not allow more than one row with the same target_dag_id / + partition_key where created_dag_run_id is null, and this is what the + `_lock_asset_model` mutex control is for. In case a duplicate somehow + gets created, we always work on the latest matching APDR record. """ id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)