mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
fix: Prevent executions from displaying as running forever (#5563)
* fix: Prevent executions from displaying as running forever * fix: Correct migration query
This commit is contained in:
parent
534629c146
commit
46d9ac6c6f
|
@ -472,7 +472,6 @@ export function hookFunctionsPreExecute(parentProcessMode?: string): IWorkflowEx
|
||||||
fullExecutionData.status = 'running';
|
fullExecutionData.status = 'running';
|
||||||
|
|
||||||
const flattenedExecutionData = ResponseHelper.flattenExecutionData(fullExecutionData);
|
const flattenedExecutionData = ResponseHelper.flattenExecutionData(fullExecutionData);
|
||||||
|
|
||||||
await Db.collections.Execution.update(
|
await Db.collections.Execution.update(
|
||||||
this.executionId,
|
this.executionId,
|
||||||
flattenedExecutionData as IExecutionFlattedDb,
|
flattenedExecutionData as IExecutionFlattedDb,
|
||||||
|
@ -578,7 +577,11 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
|
||||||
saveDataSuccessExecution;
|
saveDataSuccessExecution;
|
||||||
}
|
}
|
||||||
|
|
||||||
const workflowDidSucceed = !fullRunData.data.resultData.error;
|
const workflowHasCrashed = fullRunData.status === 'crashed';
|
||||||
|
const workflowDidSucceed = !fullRunData.data.resultData.error && !workflowHasCrashed;
|
||||||
|
let workflowStatusFinal: ExecutionStatus = workflowDidSucceed ? 'success' : 'failed';
|
||||||
|
if (workflowHasCrashed) workflowStatusFinal = 'crashed';
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(workflowDidSucceed && saveDataSuccessExecution === 'none') ||
|
(workflowDidSucceed && saveDataSuccessExecution === 'none') ||
|
||||||
(!workflowDidSucceed && saveDataErrorExecution === 'none')
|
(!workflowDidSucceed && saveDataErrorExecution === 'none')
|
||||||
|
@ -626,7 +629,7 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
|
||||||
stoppedAt: fullRunData.stoppedAt,
|
stoppedAt: fullRunData.stoppedAt,
|
||||||
workflowData: pristineWorkflowData,
|
workflowData: pristineWorkflowData,
|
||||||
waitTill: fullRunData.waitTill,
|
waitTill: fullRunData.waitTill,
|
||||||
status: fullRunData.status,
|
status: workflowStatusFinal,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.retryOf !== undefined) {
|
if (this.retryOf !== undefined) {
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
import { logMigrationEnd, logMigrationStart } from '@db/utils/migrationHelpers';
|
||||||
|
import config from '@/config';
|
||||||
|
|
||||||
|
export class UpdateRunningExecutionStatus1677236788851 implements MigrationInterface {
|
||||||
|
name = 'UpdateRunningExecutionStatus1677236788851';
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
logMigrationStart(this.name);
|
||||||
|
const tablePrefix = config.getEnv('database.tablePrefix');
|
||||||
|
|
||||||
|
await queryRunner.query(
|
||||||
|
`UPDATE \`${tablePrefix}execution_entity\` SET status='failed' WHERE status = 'running' AND finished=0 AND \`stoppedAt\` IS NOT NULL;`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`UPDATE \`${tablePrefix}execution_entity\` SET status='success' WHERE status = 'running' AND finished=1 AND \`stoppedAt\` IS NOT NULL;`,
|
||||||
|
);
|
||||||
|
|
||||||
|
logMigrationEnd(this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {}
|
||||||
|
}
|
|
@ -33,6 +33,7 @@ import { CreateLdapEntities1674509946020 } from './1674509946020-CreateLdapEntit
|
||||||
import { PurgeInvalidWorkflowConnections1675940580449 } from './1675940580449-PurgeInvalidWorkflowConnections';
|
import { PurgeInvalidWorkflowConnections1675940580449 } from './1675940580449-PurgeInvalidWorkflowConnections';
|
||||||
import { AddStatusToExecutions1674138566000 } from './1674138566000-AddStatusToExecutions';
|
import { AddStatusToExecutions1674138566000 } from './1674138566000-AddStatusToExecutions';
|
||||||
import { MigrateExecutionStatus1676996103000 } from './1676996103000-MigrateExecutionStatus';
|
import { MigrateExecutionStatus1676996103000 } from './1676996103000-MigrateExecutionStatus';
|
||||||
|
import { UpdateRunningExecutionStatus1677236788851 } from './1677236788851-UpdateRunningExecutionStatus';
|
||||||
|
|
||||||
export const mysqlMigrations = [
|
export const mysqlMigrations = [
|
||||||
InitialMigration1588157391238,
|
InitialMigration1588157391238,
|
||||||
|
@ -70,4 +71,5 @@ export const mysqlMigrations = [
|
||||||
PurgeInvalidWorkflowConnections1675940580449,
|
PurgeInvalidWorkflowConnections1675940580449,
|
||||||
AddStatusToExecutions1674138566000,
|
AddStatusToExecutions1674138566000,
|
||||||
MigrateExecutionStatus1676996103000,
|
MigrateExecutionStatus1676996103000,
|
||||||
|
UpdateRunningExecutionStatus1677236788851,
|
||||||
];
|
];
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
import { logMigrationEnd, logMigrationStart } from '@db/utils/migrationHelpers';
|
||||||
|
import config from '@/config';
|
||||||
|
|
||||||
|
export class UpdateRunningExecutionStatus1677236854063 implements MigrationInterface {
|
||||||
|
name = 'UpdateRunningExecutionStatus1677236854063';
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
logMigrationStart(this.name);
|
||||||
|
const tablePrefix = config.getEnv('database.tablePrefix');
|
||||||
|
|
||||||
|
await queryRunner.query(
|
||||||
|
`UPDATE "${tablePrefix}execution_entity" SET "status" = 'failed' WHERE "status" = 'running' AND "finished"=false AND "stoppedAt" IS NOT NULL;`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`UPDATE "${tablePrefix}execution_entity" SET "status" = 'success' WHERE "status" = 'running' AND "finished"=true AND "stoppedAt" IS NOT NULL;`,
|
||||||
|
);
|
||||||
|
|
||||||
|
logMigrationEnd(this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {}
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ import { CreateLdapEntities1674509946020 } from './1674509946020-CreateLdapEntit
|
||||||
import { PurgeInvalidWorkflowConnections1675940580449 } from './1675940580449-PurgeInvalidWorkflowConnections';
|
import { PurgeInvalidWorkflowConnections1675940580449 } from './1675940580449-PurgeInvalidWorkflowConnections';
|
||||||
import { AddStatusToExecutions1674138566000 } from './1674138566000-AddStatusToExecutions';
|
import { AddStatusToExecutions1674138566000 } from './1674138566000-AddStatusToExecutions';
|
||||||
import { MigrateExecutionStatus1676996103000 } from './1676996103000-MigrateExecutionStatus';
|
import { MigrateExecutionStatus1676996103000 } from './1676996103000-MigrateExecutionStatus';
|
||||||
|
import { UpdateRunningExecutionStatus1677236854063 } from './1677236854063-UpdateRunningExecutionStatus';
|
||||||
|
|
||||||
export const postgresMigrations = [
|
export const postgresMigrations = [
|
||||||
InitialMigration1587669153312,
|
InitialMigration1587669153312,
|
||||||
|
@ -66,4 +67,5 @@ export const postgresMigrations = [
|
||||||
PurgeInvalidWorkflowConnections1675940580449,
|
PurgeInvalidWorkflowConnections1675940580449,
|
||||||
AddStatusToExecutions1674138566000,
|
AddStatusToExecutions1674138566000,
|
||||||
MigrateExecutionStatus1676996103000,
|
MigrateExecutionStatus1676996103000,
|
||||||
|
UpdateRunningExecutionStatus1677236854063,
|
||||||
];
|
];
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
import { logMigrationEnd, logMigrationStart } from '@db/utils/migrationHelpers';
|
||||||
|
import config from '@/config';
|
||||||
|
|
||||||
|
export class UpdateRunningExecutionStatus1677237073720 implements MigrationInterface {
|
||||||
|
name = 'UpdateRunningExecutionStatus1677237073720';
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
logMigrationStart(this.name);
|
||||||
|
const tablePrefix = config.getEnv('database.tablePrefix');
|
||||||
|
|
||||||
|
await queryRunner.query(
|
||||||
|
`UPDATE "${tablePrefix}execution_entity" SET "status" = 'failed' WHERE "status" = 'running' AND "finished"=0 AND "stoppedAt" IS NOT NULL;`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`UPDATE "${tablePrefix}execution_entity" SET "status" = 'success' WHERE "status" = 'running' AND "finished"=1 AND "stoppedAt" IS NOT NULL;`,
|
||||||
|
);
|
||||||
|
|
||||||
|
logMigrationEnd(this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {}
|
||||||
|
}
|
|
@ -30,6 +30,7 @@ import { CreateLdapEntities1674509946020 } from './1674509946020-CreateLdapEntit
|
||||||
import { PurgeInvalidWorkflowConnections1675940580449 } from './1675940580449-PurgeInvalidWorkflowConnections';
|
import { PurgeInvalidWorkflowConnections1675940580449 } from './1675940580449-PurgeInvalidWorkflowConnections';
|
||||||
import { AddStatusToExecutions1674138566000 } from './1674138566000-AddStatusToExecutions';
|
import { AddStatusToExecutions1674138566000 } from './1674138566000-AddStatusToExecutions';
|
||||||
import { MigrateExecutionStatus1676996103000 } from './1676996103000-MigrateExecutionStatus';
|
import { MigrateExecutionStatus1676996103000 } from './1676996103000-MigrateExecutionStatus';
|
||||||
|
import { UpdateRunningExecutionStatus1677237073720 } from './1677237073720-UpdateRunningExecutionStatus';
|
||||||
|
|
||||||
const sqliteMigrations = [
|
const sqliteMigrations = [
|
||||||
InitialMigration1588102412422,
|
InitialMigration1588102412422,
|
||||||
|
@ -64,6 +65,7 @@ const sqliteMigrations = [
|
||||||
PurgeInvalidWorkflowConnections1675940580449,
|
PurgeInvalidWorkflowConnections1675940580449,
|
||||||
AddStatusToExecutions1674138566000,
|
AddStatusToExecutions1674138566000,
|
||||||
MigrateExecutionStatus1676996103000,
|
MigrateExecutionStatus1676996103000,
|
||||||
|
UpdateRunningExecutionStatus1677237073720,
|
||||||
];
|
];
|
||||||
|
|
||||||
export { sqliteMigrations };
|
export { sqliteMigrations };
|
||||||
|
|
Loading…
Reference in a new issue