From 36b5f1d19d9944e27a86616e55f09db6ba1d03a3 Mon Sep 17 00:00:00 2001 From: giles Date: Fri, 27 Feb 2026 14:44:04 +0000 Subject: [PATCH] Fix blog startup deadlock: use direct DB instead of self-HTTP call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ghost_sync was calling blog's own /internal/data/page-config-ensure via HTTP during startup, but the server isn't listening yet — causing a retry loop that times out Hypercorn. Replace with direct DB insert using the existing session. Co-Authored-By: Claude Opus 4.6 --- blog/bp/blog/ghost/ghost_sync.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/blog/bp/blog/ghost/ghost_sync.py b/blog/bp/blog/ghost/ghost_sync.py index dd6d60c..0c97f14 100644 --- a/blog/bp/blog/ghost/ghost_sync.py +++ b/blog/bp/blog/ghost/ghost_sync.py @@ -248,13 +248,24 @@ async def _upsert_post(sess: AsyncSession, gp: Dict[str, Any], author_map: Dict[ finally: sess.autoflush = old_autoflush - # Auto-create PageConfig for pages (blog now owns this table) + # Auto-create PageConfig for pages (blog owns this table — direct DB, + # not via HTTP, since this may run during startup before the server is ready) if obj.is_page: - await fetch_data( - "blog", "page-config-ensure", - params={"container_type": "page", "container_id": obj.id}, - required=False, - ) + from sqlalchemy import select + from shared.models.page_config import PageConfig + existing = (await sess.execute( + select(PageConfig).where( + PageConfig.container_type == "page", + PageConfig.container_id == obj.id, + ) + )).scalar_one_or_none() + if existing is None: + sess.add(PageConfig( + container_type="page", + container_id=obj.id, + features={}, + )) + await sess.flush() return obj, old_status