Skip to content

Commit

Permalink
Merge pull request #145 from VerstraeteBert/fix-pg-create-tasks
Browse files Browse the repository at this point in the history
Fix: Wrap PGExecutionDAO createTasks in a single transaction
  • Loading branch information
v1r3n committed May 9, 2024
2 parents e669ab9 + cad47f4 commit 8d8588c
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,10 @@ private static String taskKey(TaskModel task) {
public List<TaskModel> createTasks(List<TaskModel> tasks) {
List<TaskModel> created = Lists.newArrayListWithCapacity(tasks.size());

for (TaskModel task : tasks) {
withTransaction(
connection -> {
withTransaction(
connection -> {
for (TaskModel task : tasks) {

validate(task);

task.setScheduledTime(System.currentTimeMillis());
Expand All @@ -155,7 +156,7 @@ public List<TaskModel> createTasks(List<TaskModel> tasks) {
+ task.getReferenceTaskName()
+ ", key="
+ taskKey);
return;
continue;
}

insertOrUpdateTaskData(connection, task);
Expand All @@ -164,8 +165,8 @@ public List<TaskModel> createTasks(List<TaskModel> tasks) {
updateTask(connection, task);

created.add(task);
});
}
}
});

return created;
}
Expand Down

0 comments on commit 8d8588c

Please sign in to comment.