From df4ab856c7597e6fe28b466ba8419257de8a1af7 Mon Sep 17 00:00:00 2001 From: Chlins Zhang Date: Mon, 17 Jun 2024 18:29:43 +0800 Subject: [PATCH] fix: update the execution sweep sql to resolve the exec deletion conflict (#20603) fix: update the execution sweep sql to resolve the exec deleteion conflict Resolve the execution deleteion conflict when there are tasks still referenced by the execution, remained execs can wait for next sweep cycle. Signed-off-by: chlins Co-authored-by: Wang Yan --- src/pkg/task/sweep_manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkg/task/sweep_manager.go b/src/pkg/task/sweep_manager.go index 95c96b8041..e82131fbc6 100644 --- a/src/pkg/task/sweep_manager.go +++ b/src/pkg/task/sweep_manager.go @@ -176,7 +176,7 @@ func (sm *sweepManager) Clean(ctx context.Context, execIDs []int64) error { return errors.Wrap(err, "failed to delete tasks") } // delete executions - sql = fmt.Sprintf("DELETE FROM execution WHERE id IN (%s)", orm.ParamPlaceholderForIn(len(params))) + sql = fmt.Sprintf("DELETE FROM execution WHERE id IN (%s) AND id NOT IN (SELECT DISTINCT execution_id FROM task)", orm.ParamPlaceholderForIn(len(params))) _, err = ormer.Raw(sql, params...).Exec() if err != nil { return errors.Wrap(err, "failed to delete executions")