dgvj-work commented on code in PR #71459:
URL: https://github.com/apache/airflow/pull/71459#discussion_r4021935364
##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_run.py:
##########
@@ -438,6 +438,31 @@ def test_get_dag_run_not_found(self, test_client):
body = response.json()
assert body["detail"] == "The DagRun with dag_id: `test_dag1` and
run_id: `invalid` was not found"
+ @pytest.mark.usefixtures("configure_git_connection_for_dag_bundle")
+ def test_get_dag_run_dag_versions_query_count_does_not_scale_with_ti_count(
+ self, test_client, dag_maker, session
+ ):
+ query_counts = []
+ for ti_count in (3, 20):
+ dag_id = f"test_get_dag_run_prefetch_{ti_count}"
+ with dag_maker(dag_id=dag_id, schedule=None,
start_date=START_DATE1, serialized=True):
+ for i in range(ti_count):
+ EmptyOperator(task_id=f"task_{i}")
+ dag_run = dag_maker.create_dagrun(run_id=f"run_{ti_count}",
state=DagRunState.SUCCESS)
+ session.commit()
+
+ with count_queries() as result:
+ response =
test_client.get(f"/dags/{dag_id}/dagRuns/{dag_run.run_id}")
+
+ assert response.status_code == 200
+ assert response.json()["dag_versions"]
+ query_counts.append(sum(result.values()))
+
+ assert query_counts[0] == query_counts[1], (
Review Comment:
Replaced the query-count check. It now serializes a bundle-versioned run
that still has TIH after a full `run_on_latest_version` clear and asserts
`task_instances` and `task_instances_histories` stay unloaded. That fails if
`get_dag_run()` stops calling the DISTINCT prefetch.
--
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]