Skip to content

Commit 7e620f1

Browse files
authored
fix: stop deleting execution steps on step delete (#852)
## Problem RDS CPU Utilisation spikes when user deletes a step due to the deletion of corresponding execution steps. ## Solution **Improvements**: - Do not delete the execution steps as there is no impact to the pipe when execution steps are not deleted - Only impact is at the retrieval of test execution steps, where deleted steps have to be filtered out. This tradeoff is deemed acceptable as the query to delete execution steps is expensive for Pipes with many executions. ## Tests - [ ] Deleting steps does not affect Pipes, i.e. data for existing steps remain and Pipe can execute properly - [ ] Adding new steps to a Pipe works and Pipe executes properly
1 parent f1e9560 commit 7e620f1

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

packages/backend/src/graphql/mutations/delete-step.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ const deleteStep: MutationResolvers['deleteStep'] = async (
4040
}
4141

4242
const stepIds = steps.map((step) => step.id)
43-
await Step.relatedQuery('executionSteps', trx).for(stepIds).delete()
43+
44+
/**
45+
* NOTE: do not delete execution steps
46+
* The deletion causes RDS CPU Utilisation to spike
47+
*/
48+
// await Step.relatedQuery('executionSteps', trx).for(stepIds).delete()
4449
await Step.query(trx).findByIds(stepIds).delete()
4550

4651
await steps[0].flow

packages/backend/src/helpers/get-test-execution-steps.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ export async function getTestExecutionSteps(
2525

2626
if (flow.testExecution && !ignoreTestExecutionId) {
2727
const testExecutionSteps = flow.testExecution.executionSteps
28-
testExecutionSteps.sort((a, b) => a.step.position - b.step.position)
28+
29+
/**
30+
* NOTE: filters out test execution steps for steps that have been deleted
31+
*/
32+
testExecutionSteps
33+
.filter((e) => e.step)
34+
.sort((a, b) => a.step.position - b.step.position)
2935

3036
/**
3137
* Sanity check to ensure not more than 1 execution step per step is returned

packages/backend/src/services/test-step.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const testStep = async (options: TestStepOptions): Promise<TestStepResult> => {
3838

3939
const testExecutionSteps = await getTestExecutionSteps(flow.id)
4040
const testActionExecutionSteps = testExecutionSteps.filter(
41-
(executionStep) => executionStep.step.isAction,
41+
(executionStep) => executionStep.step && executionStep.step.isAction,
4242
)
4343

4444
/**

0 commit comments

Comments
 (0)