From cad47f486b513cf5bb879243f0ab63ed0895781d Mon Sep 17 00:00:00 2001 From: Bert Verstraete Date: Tue, 7 May 2024 17:47:38 +0200 Subject: [PATCH] Wrap PGExecutionDAO createTasks in a single transaction --- .../postgres/dao/PostgresExecutionDAO.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/postgres-persistence/src/main/java/com/netflix/conductor/postgres/dao/PostgresExecutionDAO.java b/postgres-persistence/src/main/java/com/netflix/conductor/postgres/dao/PostgresExecutionDAO.java index 5ac642e93..aa5233f6b 100644 --- a/postgres-persistence/src/main/java/com/netflix/conductor/postgres/dao/PostgresExecutionDAO.java +++ b/postgres-persistence/src/main/java/com/netflix/conductor/postgres/dao/PostgresExecutionDAO.java @@ -136,9 +136,10 @@ private static String taskKey(TaskModel task) { public List createTasks(List tasks) { List created = Lists.newArrayListWithCapacity(tasks.size()); - for (TaskModel task : tasks) { - withTransaction( - connection -> { + withTransaction( + connection -> { + for (TaskModel task : tasks) { + validate(task); task.setScheduledTime(System.currentTimeMillis()); @@ -155,7 +156,7 @@ public List createTasks(List tasks) { + task.getReferenceTaskName() + ", key=" + taskKey); - return; + continue; } insertOrUpdateTaskData(connection, task); @@ -164,8 +165,8 @@ public List createTasks(List tasks) { updateTask(connection, task); created.add(task); - }); - } + } + }); return created; }