Fix blog startup deadlock: use direct DB instead of self-HTTP call
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user