Skip to content

Commit

Permalink
fix(jdbc): delete the executor state at the correct stage
Browse files Browse the repository at this point in the history
Without this change, the executor state is deleted when the execution is terminated.
Then the last execution message is emitted, which goes again into the queue wich recreates the executor state.
  • Loading branch information
loicmathieu committed Feb 11, 2025
1 parent e7f551e commit 753f7b1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions jdbc/src/main/java/io/kestra/jdbc/runner/JdbcExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,13 @@ private void toExecution(Executor executor, boolean ignoreFailure) {
}

if (!shouldSend) {
// delete the execution from the state storage if ended
// IMPORTANT: it must be done here as it's when the execution arrives 'again' with a terminated state,
// so we are sure at this point that no new executions will be created otherwise the tate storage would be re-created by the execution queue.
if (executorService.canBePurged(executor)) {
executorStateStorage.delete(executor.getExecution());
}

return;
}

Expand All @@ -957,11 +964,6 @@ private void toExecution(Executor executor, boolean ignoreFailure) {
((JdbcQueue<Execution>) this.executionQueue).emitOnly(null, executor.getExecution());
}

// delete the execution from the state storage if ended
if (executorService.canBePurged(executor)) {
executorStateStorage.delete(executor.getExecution());
}

Execution execution = executor.getExecution();
// handle flow triggers on state change
if (!execution.getState().getCurrent().equals(executor.getOriginalState())) {
Expand Down

0 comments on commit 753f7b1

Please sign in to comment.