fix(agentctl): re-lock write txn after schema DDL for claim CAS

This commit is contained in:
WeiCHEN
2026-09-23 16:29:12 +08:00
parent 7d864828b5
commit b2c582dc5a
+7 -2
View File
@@ -588,13 +588,18 @@ class Repo:
db.execute('PRAGMA busy_timeout=5000')
if write:
db.execute('PRAGMA synchronous=FULL')
# DDL inside ensure_schema implicitly commits any open txn; take the
# exclusive lock only after schema is stable so claim/lease CAS holds.
db.execute('BEGIN IMMEDIATE')
ensure_schema(db)
if db.in_transaction:
db.execute('COMMIT')
db.execute('BEGIN IMMEDIATE')
yield db
if write:
if write and db.in_transaction:
db.commit()
except BaseException:
if write:
if write and db.in_transaction:
db.rollback()
raise
finally: