Worker không chết vì SQLite locked, trang trắng không bị coi là lỗi

- tx(): chỉ ROLLBACK khi đang có transaction; BEGIN IMMEDIATE hết busy_timeout
  trước đây ném "cannot rollback - no transaction is active" che mất lỗi gốc.
- Luồng OCR/callback/coordinator chạy qua Worker.loop: lỗi được log.exception
  rồi thử lại, không còn giết luồng vĩnh viễn.
- OCR: model trả rỗng (trang trắng) thành trang không có block; output không
  parse được thì kèm 200 ký tự đầu vào thông báo lỗi.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-28 13:40:05 +00:00
parent a173348380
commit 3cbba8bd79
4 changed files with 61 additions and 21 deletions

View File

@@ -87,7 +87,10 @@ class Store:
yield db
db.execute("COMMIT")
except BaseException:
db.execute("ROLLBACK")
# BEGIN IMMEDIATE hết busy_timeout thì chưa có transaction: ROLLBACK lúc đó
# sẽ ném "no transaction is active" và che mất lỗi "database is locked" gốc.
if db.in_transaction:
db.execute("ROLLBACK")
raise
finally:
db.close()