diff --git a/packages/cli/src/config/schema.ts b/packages/cli/src/config/schema.ts index 2a082d421..a7bef6f5c 100644 --- a/packages/cli/src/config/schema.ts +++ b/packages/cli/src/config/schema.ts @@ -316,16 +316,30 @@ export const schema = { env: 'EXECUTIONS_DATA_PRUNE', }, pruneDataMaxAge: { - doc: 'How old (hours) the finished execution data has to be to get deleted', + doc: 'How old (hours) the finished execution data has to be to get soft-deleted', format: Number, default: 336, env: 'EXECUTIONS_DATA_MAX_AGE', }, - pruneDataInterval: { - doc: 'How often (minutes) execution data should be hard-deleted', + pruneDataHardDeleteBuffer: { + doc: 'How old (hours) the finished execution data has to be to get hard-deleted. By default, this buffer excludes recent executions as the user may need them while building a workflow.', format: Number, - default: 15, - env: 'EXECUTIONS_DATA_PRUNE_INTERVAL', + default: 1, + env: 'EXECUTIONS_DATA_HARD_DELETE_BUFFER', + }, + pruneDataIntervals: { + hardDelete: { + doc: 'How often (minutes) execution data should be hard-deleted', + format: Number, + default: 15, + env: 'EXECUTIONS_DATA_PRUNE_HARD_DELETE_INTERVAL', + }, + softDelete: { + doc: 'How often (minutes) execution data should be soft-deleted', + format: Number, + default: 60, + env: 'EXECUTIONS_DATA_PRUNE_SOFT_DELETE_INTERVAL', + }, }, // Additional pruning option to delete executions if total count exceeds the configured max. diff --git a/packages/cli/src/databases/repositories/execution.repository.ts b/packages/cli/src/databases/repositories/execution.repository.ts index dc09433f2..4fa541f30 100644 --- a/packages/cli/src/databases/repositories/execution.repository.ts +++ b/packages/cli/src/databases/repositories/execution.repository.ts @@ -87,8 +87,8 @@ export class ExecutionRepository extends Repository { }; private rates: Record = { - softDeletion: 1 * TIME.HOUR, - hardDeletion: config.getEnv('executions.pruneDataInterval') * TIME.MINUTE, + softDeletion: config.getEnv('executions.pruneDataIntervals.softDelete') * TIME.MINUTE, + hardDeletion: config.getEnv('executions.pruneDataIntervals.hardDelete') * TIME.MINUTE, }; private isMainInstance = config.get('generic.instanceType') === 'main'; @@ -523,9 +523,8 @@ export class ExecutionRepository extends Repository { * Permanently delete all soft-deleted executions and their binary data, in batches. */ private async hardDelete() { - // Find ids of all executions that were deleted over an hour ago const date = new Date(); - date.setHours(date.getHours() - 1); + date.setHours(date.getHours() - config.getEnv('executions.pruneDataHardDeleteBuffer')); const workflowIdsAndExecutionIds = ( await this.find({