refactor(core): Don't use DB transactions on ExecutionRepository.createNewExecution (#8002)

Saving execution data is one of the slowest DB operations in the
application, and is likely behind some of the sqlite transaction
concurrency issues we've been seeing.
This not only remove the 2 separate transactions for saving
`ExecutionEntity` and `ExecutionData`, but also remove fields from
`ExecutionData.workflowData` that don't need to be saved (like `tags`,
`shared`, `statistics`, `triggerCount`, etc).
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-12-12 14:36:56 +01:00
committed by GitHub
parent 19e88ec8a1
commit 1d870412ca
4 changed files with 63 additions and 14 deletions

View File

@@ -213,17 +213,17 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
return rest;
}
async createNewExecution(execution: ExecutionPayload) {
async createNewExecution(execution: ExecutionPayload): Promise<string> {
const { data, workflowData, ...rest } = execution;
const newExecution = await this.save(rest);
await this.executionDataRepository.save({
execution: newExecution,
workflowData,
const { identifiers: inserted } = await this.insert(rest);
const { id: executionId } = inserted[0] as { id: string };
const { connections, nodes, name } = workflowData ?? {};
await this.executionDataRepository.insert({
executionId,
workflowData: { connections, nodes, name },
data: stringify(data),
});
return newExecution;
return String(executionId);
}
async markAsCrashed(executionIds: string[]) {