fix: PG init backfill rollback scope + audit-loop state upsert registration
- db: translate INSERT OR IGNORE ... SELECT to ON CONFLICT DO NOTHING (VALUES-only regex left SELECT form untranslated -> PG syntax error); register task_audit_loop_state (task_id) in _OR_REPLACE_PK so PG INSERT OR REPLACE becomes a real upsert instead of DO NOTHING. - server: _backfill_default_quotas uses SAVEPOINT containment and no longer commits the caller's transaction, so a backfill failure cannot roll back init_db's migrate ALTERs. - worker: _coord_child_rows rolls back before column-fallback retries so a missing-column failure on PG does not cascade into InFailedSqlTransaction. - tests: test_pg_init_fix.py (translation, SQLite backfill/upsert, real-PG fresh-init + merge + upsert + backfill containment, skipped without CLOUD_TEST_PG_DSN/driver).
This commit is contained in:
1 parent
d99853b684
commit
b0347b374d
4 files changed
+381
-4
No files matched your search
@@ -5772,6 +5772,14 @@ class Worker:
|
||||
" WHERE id = ?", (cid,)).fetchone()
|
||||
fetched.append((cid, row))
|
||||
except Exception:
|
||||
# PG 下语句失败即 abort 整个事务:缺列的首次查询
|
||||
# 失败后,不先 rollback 就重查只会连环报
|
||||
# InFailedSqlTransaction。本连接只做 SELECT,rollback
|
||||
# 无副作用;SQLite 下同样无害。
|
||||
try:
|
||||
conn.rollback()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
fetched = []
|
||||
for cid in child_ids:
|
||||
@@ -5781,6 +5789,10 @@ class Worker:
|
||||
" FROM tasks WHERE id = ?", (cid,)).fetchone()
|
||||
fetched.append((cid, row))
|
||||
except Exception:
|
||||
try:
|
||||
conn.rollback()
|
||||
except Exception:
|
||||
pass
|
||||
fetched = []
|
||||
for cid in child_ids:
|
||||
row = conn.execute(
|
||||
|
||||
Reference in new issue
Block a user