mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-27 13:39:44 -08:00
refactor(core): Make executions pruning settings configurable (#7468)
This commit is contained in:
parent
c7c8048430
commit
b50376cf52
|
@ -316,16 +316,30 @@ export const schema = {
|
||||||
env: 'EXECUTIONS_DATA_PRUNE',
|
env: 'EXECUTIONS_DATA_PRUNE',
|
||||||
},
|
},
|
||||||
pruneDataMaxAge: {
|
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,
|
format: Number,
|
||||||
default: 336,
|
default: 336,
|
||||||
env: 'EXECUTIONS_DATA_MAX_AGE',
|
env: 'EXECUTIONS_DATA_MAX_AGE',
|
||||||
},
|
},
|
||||||
pruneDataInterval: {
|
pruneDataHardDeleteBuffer: {
|
||||||
doc: 'How often (minutes) execution data should be hard-deleted',
|
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,
|
format: Number,
|
||||||
default: 15,
|
default: 1,
|
||||||
env: 'EXECUTIONS_DATA_PRUNE_INTERVAL',
|
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.
|
// Additional pruning option to delete executions if total count exceeds the configured max.
|
||||||
|
|
|
@ -87,8 +87,8 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
|
||||||
};
|
};
|
||||||
|
|
||||||
private rates: Record<string, number> = {
|
private rates: Record<string, number> = {
|
||||||
softDeletion: 1 * TIME.HOUR,
|
softDeletion: config.getEnv('executions.pruneDataIntervals.softDelete') * TIME.MINUTE,
|
||||||
hardDeletion: config.getEnv('executions.pruneDataInterval') * TIME.MINUTE,
|
hardDeletion: config.getEnv('executions.pruneDataIntervals.hardDelete') * TIME.MINUTE,
|
||||||
};
|
};
|
||||||
|
|
||||||
private isMainInstance = config.get('generic.instanceType') === 'main';
|
private isMainInstance = config.get('generic.instanceType') === 'main';
|
||||||
|
@ -523,9 +523,8 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
|
||||||
* Permanently delete all soft-deleted executions and their binary data, in batches.
|
* Permanently delete all soft-deleted executions and their binary data, in batches.
|
||||||
*/
|
*/
|
||||||
private async hardDelete() {
|
private async hardDelete() {
|
||||||
// Find ids of all executions that were deleted over an hour ago
|
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
date.setHours(date.getHours() - 1);
|
date.setHours(date.getHours() - config.getEnv('executions.pruneDataHardDeleteBuffer'));
|
||||||
|
|
||||||
const workflowIdsAndExecutionIds = (
|
const workflowIdsAndExecutionIds = (
|
||||||
await this.find({
|
await this.find({
|
||||||
|
|
Loading…
Reference in a new issue