Skip to content

fix(webapp): stop slow database cleanup on project deletion#4191

Merged
d-cs merged 1 commit into
mainfrom
fix/deleteproject-soft-delete-remove-runops-cascade
Jul 8, 2026
Merged

fix(webapp): stop slow database cleanup on project deletion#4191
d-cs merged 1 commit into
mainfrom
fix/deleteproject-soft-delete-remove-runops-cascade

Conversation

@d-cs

@d-cs d-cs commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Deleting a project triggered an unbounded database cleanup that scanned the project's entire run history, so deleting a project with many runs could be very slow. Project deletion is a soft delete again: run data is retained and the deletion completes quickly.

Fix

Project deletion ran a cascade hard-delete whose BulkActionItem step filtered through a relation to TaskRun scoped by projectId. Prisma compiles that to an EXISTS-join over the project's entire TaskRun set (a large, hot table with no projectId index), and it ran on every project deletion unconditionally.

Removing the cascade-cleanup call restores the prior soft-delete behaviour: queues are removed, the project is marked deleted, and run data is retained. The cascade-cleanup service (added in #4117) had no other callers, so it and its test are deleted.

Deleting a project triggered an unbounded database cleanup that scanned the
project's entire run history, so deleting a project with many runs could be
very slow. Project deletion is a soft delete again: run data is retained and
the deletion completes quickly. The cascade-cleanup service had no other
callers, so it and its test are removed.
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Project deletion no longer performs a hard-delete cascade cleanup of run-ops data across run-ops databases. The RunOpsCascadeCleanupService and its call site in the project deletion service were removed, along with its dedicated integration test suite. A related comment in the archive branch service was reworded to remove a direct reference to the removed service, pointing instead to a general purge runbook. A changelog entry documents the fix, noting that project deletion previously could hang for projects with many runs due to slow database cleanup.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the summary and fix, but it misses the required Closes line, testing steps, changelog, screenshots, and checklist items. Add the missing template sections: Closes #issue, completed checklist, testing details, changelog summary, and screenshots or an explicit note if none.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately describes the main change to stop slow cleanup on project deletion.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/deleteproject-soft-delete-remove-runops-cascade

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@d-cs d-cs self-assigned this Jul 8, 2026
@d-cs d-cs marked this pull request as ready for review July 8, 2026 14:49

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Open in Devin Review

Comment thread apps/webapp/app/services/deleteProject.server.ts
@d-cs d-cs merged commit 80d4819 into main Jul 8, 2026
37 checks passed
@d-cs d-cs deleted the fix/deleteproject-soft-delete-remove-runops-cascade branch July 8, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants