Rollback session when advisory lock not acquired
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m13s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m13s
Prevents PgBouncer connection pool from inheriting dirty transaction state when the non-syncing worker returns. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -55,7 +55,8 @@ def register(url_prefix, title):
|
|||||||
async with get_session() as s:
|
async with get_session() as s:
|
||||||
got_lock = await s.scalar(text("SELECT pg_try_advisory_lock(900001)"))
|
got_lock = await s.scalar(text("SELECT pg_try_advisory_lock(900001)"))
|
||||||
if not got_lock:
|
if not got_lock:
|
||||||
return # another worker is syncing
|
await s.rollback() # clean up before returning connection to pool
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
await sync_all_content_from_ghost(s)
|
await sync_all_content_from_ghost(s)
|
||||||
await s.commit()
|
await s.commit()
|
||||||
|
|||||||
Reference in New Issue
Block a user