This is an automated email from the ASF dual-hosted git repository.
choo121600 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 3047ad7fa3c Fix autorefresh for deadlines and paused dags (#67249)
3047ad7fa3c is described below
commit 3047ad7fa3cbb8d442840111bed7febfab0a767e
Author: Brent Bovenzi <[email protected]>
AuthorDate: Wed May 20 13:43:39 2026 -0400
Fix autorefresh for deadlines and paused dags (#67249)
* UI: Stop polling getLatestRunInfo on paused Dags with no active runs
useRefreshOnNewDagRuns was polling every 5 s indefinitely whenever
hasPendingRuns was false, including on Dags that are paused and have
no active runs. Pass isPaused from the Dag details into the hook and
skip the refetchInterval when the Dag is paused and idle.
* UI: Stop polling deadlines when no runs are active
useDeadlines was polling at full rate on any non-paused Dag, even with
no active runs. Pass checkPendingRuns: true to useAutoRefresh so the
deadline query pauses when idle and resumes automatically when a new
run starts.
* UI: Skip deadline instances fetch when Dag has no deadline alerts
If the Dag has no deadline alerts configured, there can never be any
deadline instances. Fetch the alert config first (one-shot) and gate
the useDeadlines query on total_entries > 0, avoiding the polling
request entirely for the common case.
---
airflow-core/src/airflow/ui/src/pages/Dag/Dag.tsx | 2 +-
.../src/airflow/ui/src/pages/Dag/Overview/DagDeadlines.tsx | 8 ++++++--
airflow-core/src/airflow/ui/src/queries/useDeadlines.ts | 2 +-
airflow-core/src/airflow/ui/src/queries/useRefreshOnNewDagRuns.ts | 8 ++++++--
4 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/airflow-core/src/airflow/ui/src/pages/Dag/Dag.tsx
b/airflow-core/src/airflow/ui/src/pages/Dag/Dag.tsx
index c4795619c77..a4ba1a638d3 100644
--- a/airflow-core/src/airflow/ui/src/pages/Dag/Dag.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/Dag/Dag.tsx
@@ -88,7 +88,7 @@ export const Dag = () => {
// Ensures continuous refresh to detect new runs when there's no
// pending state and new runs are initiated from other page
- useRefreshOnNewDagRuns(dagId, hasPendingRuns);
+ useRefreshOnNewDagRuns(dagId, hasPendingRuns, dag?.is_paused);
const {
data: latestRun,
diff --git
a/airflow-core/src/airflow/ui/src/pages/Dag/Overview/DagDeadlines.tsx
b/airflow-core/src/airflow/ui/src/pages/Dag/Overview/DagDeadlines.tsx
index d844c0002de..554e78aaba5 100644
--- a/airflow-core/src/airflow/ui/src/pages/Dag/Overview/DagDeadlines.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/Dag/Overview/DagDeadlines.tsx
@@ -39,10 +39,14 @@ export const DagDeadlines = ({ dagId }: DagDeadlinesProps)
=> {
const { t: translate } = useTranslation("dag");
const [modalOpen, setModalOpen] = useState(false);
- const { data, error, isLoading } = useDeadlines({ dagId, limit: LIMIT });
-
const { data: alertData } = useDeadlinesServiceGetDagDeadlineAlerts({ dagId,
limit: 100 });
+ const { data, error, isLoading } = useDeadlines({
+ dagId,
+ enabled: (alertData?.total_entries ?? 0) > 0,
+ limit: LIMIT,
+ });
+
const alertMap = new Map<string, DeadlineAlertResponse>();
for (const alert of alertData?.deadline_alerts ?? []) {
diff --git a/airflow-core/src/airflow/ui/src/queries/useDeadlines.ts
b/airflow-core/src/airflow/ui/src/queries/useDeadlines.ts
index e7f4b1750d0..32a6dfab98a 100644
--- a/airflow-core/src/airflow/ui/src/queries/useDeadlines.ts
+++ b/airflow-core/src/airflow/ui/src/queries/useDeadlines.ts
@@ -27,7 +27,7 @@ type UseDeadlinesParams = {
};
export const useDeadlines = ({ dagId, enabled, limit, offset = 0 }:
UseDeadlinesParams) => {
- const refetchInterval = useAutoRefresh({ dagId });
+ const refetchInterval = useAutoRefresh({ checkPendingRuns: true, dagId });
return useDeadlinesServiceGetDeadlines(
{
diff --git a/airflow-core/src/airflow/ui/src/queries/useRefreshOnNewDagRuns.ts
b/airflow-core/src/airflow/ui/src/queries/useRefreshOnNewDagRuns.ts
index d959ccb8d75..48c2eb864db 100644
--- a/airflow-core/src/airflow/ui/src/queries/useRefreshOnNewDagRuns.ts
+++ b/airflow-core/src/airflow/ui/src/queries/useRefreshOnNewDagRuns.ts
@@ -28,7 +28,11 @@ import {
import { gridQueryKeys } from "./gridViewQueryKeys";
import { useConfig } from "./useConfig";
-export const useRefreshOnNewDagRuns = (dagId: string, hasPendingRuns: boolean
| undefined) => {
+export const useRefreshOnNewDagRuns = (
+ dagId: string,
+ hasPendingRuns: boolean | undefined,
+ isPaused?: boolean,
+) => {
const queryClient = useQueryClient();
const hasSyncedLatestRunRef = useRef(false);
const previousLatestRunSignatureRef = useRef<string>("");
@@ -38,7 +42,7 @@ export const useRefreshOnNewDagRuns = (dagId: string,
hasPendingRuns: boolean |
const { data: latestDagRun } = useDagServiceGetLatestRunInfo({ dagId },
undefined, {
enabled: Boolean(dagId),
- refetchInterval: Boolean(dagId) && !hasPendingRuns ? pollIntervalMs :
false,
+ refetchInterval: Boolean(dagId) && !hasPendingRuns && !isPaused ?
pollIntervalMs : false,
});
useEffect(() => {