Repository navigation
feat: paginate delete blockers - #8238
Draft
grantfitzsimmons wants to merge 70 commits into
Draft
grantfitzsimmons wants to merge 70 commits into
grantfitzsimmons wants to merge 70 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
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
|
Warning One or more dependencies are approaching or past End-of-Life. |
… cascade relationships
This was
linked to
issues
Oct 14, 2026
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.
Authored by @melton-jason
Primarily fixes #7515
Also fixes #2231, #5147, #4592
Description
The Problem
The previous implementation of Delete Blockers relied on Django's ORM (see ForeignKey.on_delete and Collector.collect) to collect all records that would prevent object deletion, and add them to a list.
The issue with this implementation is that some objects can have hundreds of thousands (or more) of references that must all be put into this list at the same time. (e.g., Agents through nearly all table's createdByAgent and modifiedByAgent relationships,TreeDef records or high-level Tree nodes, etc.).
Relevant sections of old Delete Blocker code
specify7/specifyweb/specify/models.py
Lines 13 to 17 in 41ee340
specify7/specifyweb/backend/delete_blockers/views.py
Lines 41 to 44 in 41ee340
This led to a major scalability problem where the amount of memory required to hold all of the record references at once could easily exceed what the server can handle.
See #7515 (comment) for more information
The Solution
To fix the problem of having to hold all references in memory at once, the solution is to only hold a section/portion of total referenced records in memory at once, and let the requester (in most cases the frontend) page through the records to retrieve smaller sections.
This solution utilizes a type of Pagination called Keyset or Cursor Pagination. This type of pagination is far more performant than OFFSET pagination (which scales linearly based on the OFFSET amount).
User Experience
View Parent Resource Button
This was a miscellaneous feature added in the PR that also greatly helps Delete Blockers.
Records that are dependent on some other record will have a button appear on their DataEntry form called "View Parent Resource".
When clicked, the button will display the resource's parent.
parent_resource_demo.mov
Basic Delete Blocker Interface
When all of the blocking records reference the "main" record
delete_blocker_basic_demo.mov
Below is a more complicated breakdown for Delete Blockers on an Agent:
More Complicated Delete Blocker Interface
When there are delete blockers for records that would be deleted alongside the base record
Consider the following case for a CollectionObject where one or more Preparations are being used in Interactions:
delete_blocker_cascade_demo.mov
Below is a more in-depth breakdown of the current UI:
Linked Records
Tree Records