Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 24 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/cli/src/databases/repositories/execution.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
return String(executionId);
}

async markAsCrashed(executionIds: string[]) {
async markAsCrashed(executionIds: string | string[]) {
if (!Array.isArray(executionIds)) executionIds = [executionIds];

await this.update(
{ id: In(executionIds) },
{
Expand Down Expand Up @@ -749,4 +751,13 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {

return executions.map(({ id }) => id);
}

async allCurrentExecutionIds() {
const executions = await this.find({
select: ['id'],
where: { status: In(['new', 'running']) },
});

return executions.map(({ id }) => id);
}
ivov marked this conversation as resolved.
Show resolved Hide resolved
}
14 changes: 2 additions & 12 deletions packages/cli/src/eventbus/MessageEventBus/MessageEventBus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,8 @@ export class MessageEventBus extends EventEmitter {
// start actual recovery process and write recovery process flag file
this.logWriter?.startRecoveryProcess();
for (const executionId of unfinishedExecutionIds) {
this.logger.warn(`Attempting to recover execution ${executionId}`);
if (!unsentAndUnfinished.unfinishedExecutions[executionId]?.length) {
this.logger.debug(
`No event messages found, marking execution ${executionId} as 'crashed'`,
);
await this.executionRepository.markAsCrashed([executionId]);
} else {
await this.recoveryService.recover(
executionId,
unsentAndUnfinished.unfinishedExecutions[executionId],
);
}
const logMesssages = unsentAndUnfinished.unfinishedExecutions[executionId];
await this.recoveryService.recoverFromLogs(executionId, logMesssages);
}
}
// remove the recovery process flag file
Expand Down
Loading
Loading