Why do new pages 404 after a deploy on a replicated GreenStack site?
This affects Umbraco 17 sites running 2 or more replicas. You publish a new page and it works, but after the next deploy or restart it returns a 404. Republishing brings it back, until the next restart. Rebuilding the database cache, the memory cache or the Examine indexes doesn’t help.
Why it happens
Section titled “Why it happens”When several servers share one database, Umbraco elects one of them to be the “scheduling publisher” and makes the others “subscribers”. Since Umbraco 17.4, a subscriber never saves page URLs to the database: it assumes the scheduling publisher has done that. On GreenStack the back office runs on every replica, so you can publish from a subscriber, and then nothing saves the new page’s URL.
The page still works at first, because every replica keeps its URLs in memory. When a replica restarts, it reloads its URLs from the database. The new page isn’t there, so it returns a 404.
Umbraco’s answer is that when the back office is load balanced, every server must be a scheduling publisher (see Umbraco issue #23569).
How to fix it
Section titled “How to fix it”Add the load balancing configuration from step 2.9 of the Umbraco 17 getting started guide and deploy it. The part that fixes this is the LoadBalancedBackOfficeComposer, which makes every replica a scheduling publisher.
Or install version 1.1.0 or later of the UmbHost GreenStack NuGet package, which sets this up for you when your site runs 2 or more replicas.
Repair the pages that are already affected
Section titled “Repair the pages that are already affected”The fix stops new pages being affected. Pages published before it still have no saved URL. To see which ones, run this against your site’s database:
SELECT n.id, n.uniqueId, n.text, n.pathFROM umbracoDocument dJOIN umbracoNode n ON n.id = d.nodeIdWHERE d.published = 1 AND n.trashed = 0 AND NOT EXISTS (SELECT 1 FROM umbracoDocumentUrl u WHERE u.uniqueId = n.uniqueId AND u.isDraft = 0)ORDER BY n.path;Once the fix is deployed to every replica, run the following, then restart your site in UmbPanel. Umbraco rebuilds every page URL when it starts:
DELETE FROM umbracoKeyValue WHERE [key] = 'UmbracoUrlGeneration';Run the first query again afterwards. It should return no rows.
If you’d rather we did this for you, open a support ticket.