feat(core): Expand crash recovery to cover queue mode (#9676)

This commit is contained in:
Iván Ovejero
2024-06-18 15:22:02 +02:00
committed by GitHub
parent 7e44cd7f16
commit c58621ab79
8 changed files with 262 additions and 18 deletions

View File

@@ -275,9 +275,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
},
);
this.logger.info('[Execution Recovery] Marked executions as `crashed`', {
executionIds,
});
this.logger.info('Marked executions as `crashed`', { executionIds });
}
/**
@@ -773,4 +771,18 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
return executions.map(({ id }) => id);
}
/**
* Retrieve a batch of execution IDs with `new` or `running` status, in most recent order.
*/
async getInProgressExecutionIds(batchSize: number) {
const executions = await this.find({
select: ['id'],
where: { status: In(['new', 'running']) },
order: { startedAt: 'DESC' },
take: batchSize,
});
return executions.map(({ id }) => id);
}
}