Skip to content

Commit

Permalink
refactor(core): Revamp crash recovery mechanism for main mode (#9613)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov authored Jun 7, 2024
1 parent 291d46a commit b8338e3
Show file tree
Hide file tree
Showing 10 changed files with 648 additions and 223 deletions.
11 changes: 11 additions & 0 deletions packages/cli/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,14 @@ export const GENERIC_OAUTH2_CREDENTIALS_WITH_EDITABLE_SCOPE = [
'microsoftOAuth2Api',
'highLevelOAuth2Api',
];

export const ARTIFICIAL_TASK_DATA = {
main: [
[
{
json: { isArtificialRecoveredEventItem: true },
pairedItem: undefined,
},
],
],
};
12 changes: 12 additions & 0 deletions packages/cli/src/errors/node-crashed.error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { INode } from 'n8n-workflow';
import { NodeOperationError } from 'n8n-workflow';

export class NodeCrashedError extends NodeOperationError {
constructor(node: INode) {
super(node, 'Node crashed, possible out-of-memory issue', {
message: 'Execution stopped at this node',
description:
"n8n may have run out of memory while running this execution. More context and tips on how to avoid this <a href='https://docs.n8n.io/hosting/scaling/memory-errors/' target='_blank'>in the docs</a>",
});
}
}
7 changes: 7 additions & 0 deletions packages/cli/src/errors/workflow-crashed.error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { WorkflowOperationError } from 'n8n-workflow';

export class WorkflowCrashedError extends WorkflowOperationError {
constructor() {
super('Workflow did not finish, possible out-of-memory issue');
}
}
7 changes: 3 additions & 4 deletions packages/cli/src/eventbus/MessageEventBus/MessageEventBus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
import { METRICS_EVENT_NAME } from '../MessageEventBusDestination/Helpers.ee';
import type { AbstractEventMessageOptions } from '../EventMessageClasses/AbstractEventMessageOptions';
import { getEventMessageObjectByType } from '../EventMessageClasses/Helpers';
import { ExecutionDataRecoveryService } from '../executionDataRecovery.service';
import { ExecutionRecoveryService } from '../../executions/execution-recovery.service';
import {
EventMessageAiNode,
type EventMessageAiNodeOptions,
Expand Down Expand Up @@ -68,7 +68,7 @@ export class MessageEventBus extends EventEmitter {
private readonly eventDestinationsRepository: EventDestinationsRepository,
private readonly workflowRepository: WorkflowRepository,
private readonly orchestrationService: OrchestrationService,
private readonly recoveryService: ExecutionDataRecoveryService,
private readonly recoveryService: ExecutionRecoveryService,
) {
super();
}
Expand Down Expand Up @@ -185,10 +185,9 @@ export class MessageEventBus extends EventEmitter {
);
await this.executionRepository.markAsCrashed([executionId]);
} else {
await this.recoveryService.recoverExecutionData(
await this.recoveryService.recover(
executionId,
unsentAndUnfinished.unfinishedExecutions[executionId],
true,
);
}
}
Expand Down
213 changes: 0 additions & 213 deletions packages/cli/src/eventbus/executionDataRecovery.service.ts

This file was deleted.

Loading

0 comments on commit b8338e3

Please sign in to comment.