Skip to content

Commit

Permalink
fix: delete async call with the cron job (#3127)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas authored Oct 15, 2024
1 parent 3991c76 commit ae06969
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 2 deletions.
6 changes: 5 additions & 1 deletion backend/controller/cronjobs/internal/dal/dal.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ func (d *DAL) UpdateCronJobExecution(ctx context.Context, params UpdateCronJobEx
}

func (d *DAL) DeleteCronJobsForDeployment(ctx context.Context, key model.DeploymentKey) error {
err := d.db.DeleteCronJobsForDeployment(ctx, key)
err := d.db.DeleteCronAsyncCallsForDeployment(ctx, key)
if err != nil {
return fmt.Errorf("failed to delete cron job async calls for deployment %v: %w", key, libdal.TranslatePGError(err))
}
err = d.db.DeleteCronJobsForDeployment(ctx, key)
if err != nil {
return fmt.Errorf("failed to delete cron jobs for deployment %v: %w", key, libdal.TranslatePGError(err))
}
Expand Down
1 change: 1 addition & 0 deletions backend/controller/cronjobs/internal/sql/querier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion backend/controller/cronjobs/internal/sql/queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,13 @@ SELECT EXISTS (

-- name: DeleteCronJobsForDeployment :exec
DELETE FROM cron_jobs
WHERE deployment_id = (SELECT id FROM deployments WHERE key = sqlc.arg('deployment_key')::deployment_key LIMIT 1);
WHERE deployment_id = (SELECT id FROM deployments WHERE key = sqlc.arg('deployment_key')::deployment_key LIMIT 1);


-- name: DeleteCronAsyncCallsForDeployment :exec
DELETE FROM async_calls
WHERE id IN (
SELECT last_async_call_id
FROM cron_jobs
WHERE deployment_id = (SELECT id FROM deployments WHERE key = sqlc.arg('deployment_key')::deployment_key LIMIT 1)
);
14 changes: 14 additions & 0 deletions backend/controller/cronjobs/internal/sql/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/controller/dal/internal/sql/querier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions backend/controller/dal/internal/sql/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ae06969

Please sign in to comment.