Site deletion can orphan entries, and the plugin and site caches reload under every request at once

Open
#3,306 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp

Research direction

Start with Sites/SiteManager.cs:176-181 and Storage/SystemModelBuilder.cs to trace site deletion and document storage; compare SiteManager.cs:418-422 for the existing NOT EXISTS pattern. Then read the content write transaction and the cache refresh paths in Plugins/PluginState.cs:88-108, src/plugins/FluentCMS.Plugins.MultiSite/SiteHostMap.cs:36-56, and Sites/SiteCache.cs. Done means all four acceptance cases have tests and pass.

Written by the indexing model from the issue text.

Description

area:content area:storage type:bug

Problem

  1. Site deletion can orphan content. Sites/SiteManager.cs:176-181 checks for documents and then deletes the site as two statements with no transaction. cms_document has no foreign key to the site (Storage/SystemModelBuilder.cs), while locales and roles cascade. Other instances keep the site cached for 30 s (Sites/SiteCache.cs:15, Sites/SiteResolver.cs:107-110). An entry created between the check and the delete, or on another instance within 30 s, is left in a site that no longer exists and cannot be reached, restored or purged through the API.
  2. The plugin and site caches reload under every request at once. Plugins/PluginState.cs:88-108 and src/plugins/FluentCMS.Plugins.MultiSite/SiteHostMap.cs:36-56 have a fixed 30 s lifetime and no single-flight, so every request arriving after expiry runs the query. SiteCache.Invalidate() clears every key (Sites/SiteCache.cs:89-94).

Paths are under src/FluentCMS.Core/ unless they start with src/.

Proposal

  • Delete with NOT EXISTS in one statement, as RemoveLocaleAsync does (SiteManager.cs:418-422), and re-check the site inside the content write transaction.
  • Refresh each cache once, serving the previous copy to other callers meanwhile.

Acceptance

  • A site that gains an entry during deletion is not deleted
  • A write to a site deleted on another instance is refused
  • Concurrent requests after expiry run one refresh query
  • Tests for each

Found in the code review of 17 Nov 2026.

Dominant language
C#
Stars
569
Forks
107
Avg merge
2h 49m
Merged PRs (30d)
397

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from fluentcms/FluentCMS

All issues in fluentcms/FluentCMS

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.