Skip to content

Delete the full ownership closure when deleting items - #17873

Merged
crobibero merged 2 commits into
jellyfin:release-12.zfrom
Shadowghost:fix-item-deletion
Sep 13, 2026
Merged

crobibero merged 2 commits into
jellyfin:release-12.zfrom
Shadowghost:fix-item-deletion

Conversation

@Shadowghost

Copy link
Copy Markdown
Contributor

FK_BaseItems_BaseItems_OwnerId is NO ACTION, so every item owned by something being deleted has to go in the same statement or SQLite rejects the whole delete with error 19.
DeleteItem expanded OwnerId once, over a snapshot of the id set taken before the extras it found were added, so an extra owning an extra of its own was left pointing at a deleted row.
FK_BaseItems_BaseItems_ParentId is ON DELETE CASCADE, so a child the AncestorIds closure did not list is removed by the database anyway, and anything it owned dangled the same way.

Changes
Expand both edges to a fixpoint instead, feeding the next only from ids that were not already known so ownership cycles terminate.

Code assistance
Claude Opus 5 for tracing on a real DB clone and writing the test.

Issues
Fixes #17870

@Shadowghost Shadowghost added the stable backport Backport into the next stable release label Sep 8, 2026
@jellyfin-bot

Copy link
Copy Markdown
Contributor

Jellyfin API (v 12.0.0)


Result


No differences. Specifications are equivalent

@theguymadmax theguymadmax moved this to Review in Jellyfin v12 Sep 9, 2026
@theguymadmax
theguymadmax requested a review from a team September 10, 2026 16:28
Comment thread Jellyfin.Server.Implementations/Item/ItemPersistenceService.cs Outdated
@sonarqubecloud

Copy link
Copy Markdown

@jellyfin-project-automation jellyfin-project-automation Bot added this to the v12.1 milestone Sep 12, 2026
@theguymadmax theguymadmax moved this from Review to Approved in Jellyfin v12 Sep 12, 2026
@crobibero
crobibero merged commit 705b69e into jellyfin:release-12.z Sep 13, 2026
16 of 17 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in Jellyfin v12 Sep 13, 2026
joshuaboniface pushed a commit that referenced this pull request Sep 15, 2026
Delete the full ownership closure when deleting items

Original-merge: 705b69e

Merged-by: crobibero <cody@robibe.ro>

Backported-by: Cody Robibero <cody@robibe.ro>
@crobibero crobibero removed the stable backport Backport into the next stable release label Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants