fix: prevent subscription worker deadlocks

This commit is contained in:
3252a8
2026-05-29 22:07:16 +03:00
parent 001e54cfe2
commit cab963dcdc
5 changed files with 157 additions and 9 deletions
+12
View File
@@ -0,0 +1,12 @@
from sqlalchemy import text
from sqlalchemy.ext.asyncio import AsyncSession
# Serializes background jobs that rewrite subscription rows from panel state.
SUBSCRIPTION_BACKGROUND_SYNC_LOCK_ID = 817512404897421338
async def acquire_subscription_background_sync_lock(session: AsyncSession) -> None:
await session.execute(
text("SELECT pg_advisory_xact_lock(:lock_id)"),
{"lock_id": SUBSCRIPTION_BACKGROUND_SYNC_LOCK_ID},
)