fix(core): Fix pruning of non-finished executions (#7333)

This fixes a bug in the pruning (soft-delete). The pruning was a bit too
aggressive, as it also pruned executions that weren't in an end state
yet. This only becomes an issue if there are long-running executions
(e.g. workflow with Wait node) or the prune parameters are set to keep
only a tiny number of executions.
This commit is contained in:
Tomi Turtiainen
2023-10-04 16:32:05 +03:00
committed by GitHub
parent 942d0b91fc
commit 1b4848afcb
6 changed files with 251 additions and 92 deletions

View File

@@ -360,11 +360,11 @@ export async function createManyExecutions(
/**
* Store a execution in the DB and assign it to a workflow.
*/
async function createExecution(
export async function createExecution(
attributes: Partial<ExecutionEntity & ExecutionData>,
workflow: WorkflowEntity,
) {
const { data, finished, mode, startedAt, stoppedAt, waitTill, status } = attributes;
const { data, finished, mode, startedAt, stoppedAt, waitTill, status, deletedAt } = attributes;
const execution = await Db.collections.Execution.save({
finished: finished ?? true,
@@ -374,6 +374,7 @@ async function createExecution(
stoppedAt: stoppedAt ?? new Date(),
waitTill: waitTill ?? null,
status,
deletedAt,
});
await Db.collections.ExecutionData.save({