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

fix(core): Deleting manual executions should defer deleting binary data #6680

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion packages/cli/src/WorkflowExecuteAdditionalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {

if (isManualMode && !saveManualExecutions && !fullRunData.waitTill) {
// Data is always saved, so we remove from database
await Container.get(ExecutionRepository).deleteExecution(this.executionId);
await Container.get(ExecutionRepository).deleteExecution(this.executionId, true);

return;
}
Expand Down
18 changes: 11 additions & 7 deletions packages/cli/src/databases/repositories/execution.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ function parseFiltersToQueryBuilder(

@Service()
export class ExecutionRepository extends Repository<ExecutionEntity> {
private executionDataRepository: ExecutionDataRepository;

constructor(dataSource: DataSource, executionDataRepository: ExecutionDataRepository) {
constructor(
dataSource: DataSource,
private readonly executionDataRepository: ExecutionDataRepository,
) {
super(ExecutionEntity, dataSource.manager);
this.executionDataRepository = executionDataRepository;
}

async findMultipleExecutions(
Expand Down Expand Up @@ -238,9 +238,13 @@ 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().deleteBinaryDataByExecutionIds([executionId]);
async deleteExecution(executionId: string, deferBinaryDataDeletion = false) {
const binaryDataManager = BinaryDataManager.getInstance();
if (deferBinaryDataDeletion) {
await binaryDataManager.markDataForDeletionByExecutionId(executionId);
} else {
await binaryDataManager.deleteBinaryDataByExecutionIds([executionId]);
}
return this.delete({ id: executionId });
}

Expand Down