feat: paginate delete blockers - #8238
Draft
grantfitzsimmons wants to merge 1760 commits into
Draft
grantfitzsimmons wants to merge 1760 commits into
grantfitzsimmons wants to merge 1760 commits into
Conversation
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Member
Author
|
@melton-jason Could you base this instead on |
melton-jason
force-pushed
the
issue-7515-2
branch
from
June 30, 2026 12:18
9b4c82e to
4019815
Compare
Triggered by ac5c81b on branch refs/heads/weblate-localization
Triggered by 96f24ba on branch refs/heads/weblate-localization
Triggered by 1f757ca on branch refs/heads/weblate-localization
Triggered by 533e6e7 on branch refs/heads/issue-8302
Triggered by 91e18f2 on branch refs/heads/weblate-localization
Triggered by 32b0a7e on branch refs/heads/weblate-localization
Stop unlinking tree relationships if rank not present
Stop adding extra tree joins for relationships in QueryBuilder
|
Warning One or more dependencies are approaching or past End-of-Life. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7515
Authored by @melton-jason
Description
This PR addresses a major performance bottleneck in Specify's delete blockers endpoint, which affects large databases. Currently, when fetching delete blockers for a resource, Specify attempts to load all referencing records at once into a single Python object using Django's
Collector. For highly-referenced resources (particularlyAgent, which is referenced bycreatedByAgentandmodifiedByAgentacross 515+ relationships) this eager collection can:At least two production instances have experienced kernel-invoked process restarts due to this issue. Even when requests don't crash, they can hold the Python GIL long enough to block other threads.
Solution: Paginated delete blockers
This PR introduces pagination support for the delete blockers endpoint. Instead of loading all referencing records at once, related record IDs are fetched in configurable chunks (
limit/offset). The new approach:CollectorPROTECT/protect_with_blockers) and deferred blockers (CASCADE), enabling the frontend to prioritize what's shownold_delete_blockers) for backward compatibilityChanges
New endpoint behavior (
/api/specify/delete_blockers/<model>/<id>/):limit(default: 20) andoffset(default: 0) query parametersresults: immediate blockers — relationships usingPROTECTorprotect_with_blockersnext: deferred blockers — relationships usingCASCADEtable,field,ids,offset,limit, and acompleteflag indicating whether all matching records for that relationship were fetchedlimit=0fetches all results (unpaginated)Future work
Further frontend changes are needed to adopt the paginated approach in the UI. Additional backend optimizations (e.g., query-level improvements) will be detailed in follow-up issues.
Developer Testing instructions
GET /api/specify/delete_blockers/agent/<id>/?limit=20&offset=0— should return the first 20 IDs per blocking relationship in under 1 secondcompleteflag: Verifycomplete: truewhen all related records fit withinlimit, andcomplete: falseotherwiseGET /api/specify/old_delete_blockers/<model>/<id>/should return the full, unpaginated result set identical to the previous behaviorresultsandnextarraysAgentin a database of comparable size to Geneva, Edinburgh, or Berlin to confirm no timeouts or OOM conditions occur