From e1d54d1456949f736e94930e1f71aa24ff5b3ea6 Mon Sep 17 00:00:00 2001 From: chlins Date: Mon, 17 Jun 2024 12:19:45 +0800 Subject: [PATCH] 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 --- 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 95c96b8041f..e82131fbc6f 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")