tirkarthi commented on code in PR #45977:
URL: https://github.com/apache/airflow/pull/45977#discussion_r1935403216


##########
airflow/ui/src/queries/usePatchDagRun.ts:
##########
@@ -45,7 +48,12 @@ export const usePatchDagRun = ({
   const queryClient = useQueryClient();
 
   const onSuccessFn = async () => {
-    const queryKeys = [UseDagRunServiceGetDagRunKeyFn({ dagId, dagRunId }), 
[useDagRunServiceGetDagRunsKey]];
+    const queryKeys = [
+      UseDagRunServiceGetDagRunKeyFn({ dagId, dagRunId }),
+      [useDagRunServiceGetDagRunsKey],
+      [useTaskInstanceServiceGetTaskInstancesKey, { dagId, dagRunId }],

Review Comment:
   I feel maybe this is not needed anymore. As the dagrun is in queued/running 
state there is auto refresh for task instances and on marking the dag as 
success/failed there is a refresh call made which gets the updated state for 
task instance. The PR was written before auto refresh so I am guess this can be 
removed.
   
   > The reason you see tasks being reloaded is because of the cache 
invalidation coming from.useTaskInstanceServiceGetTaskInstancesKey in 
useClearRun.ts
   
   The change is about marking the task as success/failure. I don't think 
`useClearRun` is invalidating the cache here. To validate this I tried marking 
a running dag as success with `console.log` inside `onSuccess` in `useClearRun` 
and is not triggered. Maybe I am missing something.
   
   On main : 
   
   1. Clear a dag and mark it as success
   2. The task instance state is set to success on the auto refresh cycle after 
marking the dagrun as completed.
   
   With PR it's done immediately as `onSuccess` invalidates the call.
   
   `UseTaskInstanceServiceGetTaskInstancesKeyFn({ dagId, dagRunId }, [{ dagId, 
dagRunId }])` and `[useTaskInstanceServiceGetTaskInstancesKey,{ dagId, dagRunId 
}]` in PR construct the same value. I verified it by below statement in 
`onSuccess`.
   
   ```js
   console.log(JSON.stringify(UseTaskInstanceServiceGetTaskInstancesKeyFn({ 
dagId, dagRunId }, [{ dagId, dagRunId }])) == 
JSON.stringify([useTaskInstanceServiceGetTaskInstancesKey, { dagId, dagRunId 
}]));
   ```



-- 
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]

Reply via email to