fix(core): Reduce memory consumption on BinaryDataManager.init (#6633)
fix(core): Reduce memory consumption on BinaryDataManager.init When there are a few thousand binary data file to delete, the `deleteMarkedFiles` and `deleteMarkedPersistedFiles` methods need a lot of memory to process these files, irrespective of if these files have any data or not.
This commit is contained in:
committed by
GitHub
parent
180ab8d7c2
commit
329d22f5d1
@@ -240,7 +240,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
|
||||
|
||||
async deleteExecution(executionId: string) {
|
||||
// TODO: Should this be awaited? Should we add a catch in case it fails?
|
||||
await BinaryDataManager.getInstance().deleteBinaryDataByExecutionId(executionId);
|
||||
await BinaryDataManager.getInstance().deleteBinaryDataByExecutionIds([executionId]);
|
||||
return this.delete({ id: executionId });
|
||||
}
|
||||
|
||||
@@ -392,17 +392,14 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
|
||||
return;
|
||||
}
|
||||
|
||||
const idsToDelete = executions.map(({ id }) => id);
|
||||
|
||||
const executionIds = executions.map(({ id }) => id);
|
||||
const binaryDataManager = BinaryDataManager.getInstance();
|
||||
await Promise.all(
|
||||
idsToDelete.map(async (id) => binaryDataManager.deleteBinaryDataByExecutionId(id)),
|
||||
);
|
||||
await binaryDataManager.deleteBinaryDataByExecutionIds(executionIds);
|
||||
|
||||
do {
|
||||
// Delete in batches to avoid "SQLITE_ERROR: Expression tree is too large (maximum depth 1000)" error
|
||||
const batch = idsToDelete.splice(0, 500);
|
||||
const batch = executionIds.splice(0, 500);
|
||||
await this.delete(batch);
|
||||
} while (idsToDelete.length > 0);
|
||||
} while (executionIds.length > 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user