fix(workflow-engine-*): Cleanup expired executions and reduce redis storage usage (#12795)
This commit is contained in:
committed by
GitHub
parent
c0807f5496
commit
316a325b63
@@ -47,7 +47,6 @@ export class WorkflowsModuleService<
|
||||
protected workflowOrchestratorService_: WorkflowOrchestratorService
|
||||
protected redisDisconnectHandler_: () => Promise<void>
|
||||
protected manager_: SqlEntityManager
|
||||
private clearTimeout_: NodeJS.Timeout
|
||||
|
||||
constructor(
|
||||
{
|
||||
@@ -72,13 +71,6 @@ export class WorkflowsModuleService<
|
||||
__hooks = {
|
||||
onApplicationStart: async () => {
|
||||
await this.workflowOrchestratorService_.onApplicationStart()
|
||||
|
||||
await this.clearExpiredExecutions()
|
||||
this.clearTimeout_ = setInterval(async () => {
|
||||
try {
|
||||
await this.clearExpiredExecutions()
|
||||
} catch {}
|
||||
}, 1000 * 60 * 60)
|
||||
},
|
||||
onApplicationPrepareShutdown: async () => {
|
||||
await this.workflowOrchestratorService_.onApplicationPrepareShutdown()
|
||||
@@ -86,7 +78,6 @@ export class WorkflowsModuleService<
|
||||
onApplicationShutdown: async () => {
|
||||
await this.workflowOrchestratorService_.onApplicationShutdown()
|
||||
await this.redisDisconnectHandler_()
|
||||
clearInterval(this.clearTimeout_)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -301,14 +292,6 @@ export class WorkflowsModuleService<
|
||||
return this.workflowOrchestratorService_.unsubscribe(args as any)
|
||||
}
|
||||
|
||||
private async clearExpiredExecutions() {
|
||||
return this.manager_.execute(`
|
||||
DELETE FROM workflow_execution
|
||||
WHERE retention_time IS NOT NULL AND
|
||||
updated_at <= (CURRENT_TIMESTAMP - INTERVAL '1 second' * retention_time);
|
||||
`)
|
||||
}
|
||||
|
||||
@InjectSharedContext()
|
||||
async cancel(
|
||||
workflowId: string,
|
||||
|
||||
Reference in New Issue
Block a user