SameerMesiah97 commented on code in PR #68947:
URL: https://github.com/apache/airflow/pull/68947#discussion_r3469498621
##########
airflow-core/tests/unit/models/test_serialized_dag.py:
##########
@@ -423,6 +423,27 @@ def
test_new_dag_versions_are_created_if_there_is_a_dagrun(self, dag_maker, sess
assert session.scalar(select(func.count()).select_from(DagVersion)) ==
2
assert session.scalar(select(func.count()).select_from(SDM)) == 2
+ def
test_new_dag_version_is_created_when_version_exists_but_serialized_dag_row_missing(
+ self, dag_maker, session
+ ):
+ with dag_maker("dag1") as dag:
+ PythonOperator(task_id="task1", python_callable=lambda: None)
+ assert session.scalar(select(func.count()).select_from(SDM)) == 1
+ assert session.scalar(select(func.count()).select_from(DagVersion)) ==
1
+
+ # Simulate the broken state: DagVersion present, serialized_dag row
gone.
+ session.execute(delete(SDM).where(SDM.dag_id == dag.dag_id))
+ session.flush()
+ assert session.scalar(select(func.count()).select_from(SDM)) == 0
+ assert session.scalar(select(func.count()).select_from(DagVersion)) ==
1
Review Comment:
I am just not sure how this state you are simulating can arise under normal
operation. The test simulates the issue by manually deleting the
`SerializedDagModel `row while leaving the `DagVersion` row intact. Since DAGs
are serialized during parsing, I would expect `DagVersion` and
`SerializedDagModel` to be created together under normal operation.
Could you expand the issue/PR description to explain how this state can
occur in practice? Is this intended to recover from metadata corruption, failed
migrations, manual database modification, or some known failure during
serialization?
Furthermore, have you ran into this specific failure mode yourself?
--
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]