Repository navigation
Conversation
…ties the transaction
SQLite auto-rolls-back a transaction after fatal errors (SQLITE_FULL,
SQLITE_IOERR). The usage/audit store error paths issued a bare
conn.execute("ROLLBACK") that then raised
'cannot rollback - no transaction is active', replacing the underlying
storage failure with a misleading secondary error. Production instance
of this signature: volcengine#4303 (worker pool silent for
47min after storage disruption; logs only showed the rollback error).
- Skip the explicit ROLLBACK when conn.in_transaction is already False
- Never let ROLLBACK failures shadow the exception being handled
- Always log the flush-failure traceback (was DEBUG-gated, hiding the
origin at production log levels)
Fixes the diagnostic-masking half of volcengine#4303; the wedged-worker recovery
gap is tracked separately.
This was referenced Sep 6, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Production incident in #4303: the whole async worker pool went silent for 47 minutes (460 pending jobs untouched,
in_progressfrozen,/healthstill 200) after a storage disruption during a model-swap rollout. The only diagnostic in the server logs was:That message is not the root cause — it is this repository's own error path masking the root cause.
Root cause chain (code-level)
SQLiteUsageAuditStorewraps every write batch in an explicit transaction:SQLite auto-rolls-back the active transaction after fatal errors (
SQLITE_FULL,SQLITE_IOERR, …). When that happens on a PVC/network-backed volume (the reporter's environment: K8s/Talos + Ceph RBD), by the time theexceptblock runs there is no transaction left, soconn.execute("ROLLBACK")")itself raisessqlite3.OperationalError: cannot rollback - no transaction is active— which replaces the real storage error (disk I/O error, etc.) via the standard exception-replacement rule. Three call sites were affected:_record_projection_sync(the batch flush path — the one that fired in [Bug] Crash-orphaned processing queue rows survive restarts and permanently block queue workers (RecoverStale never fires) #4303)_delete_user_data_sync_migrate_v4_to_v5_syncAdditionally, the audit worker logged flush failures with
exc_info=logger.isEnabledFor(logging.DEBUG), so at production log levels even the surviving message had no traceback — contributing to the "silent" post-mortem.Fix
_rollback_safely(conn, context=...)helper: skips the explicitROLLBACKwhenconn.in_transactionis alreadyFalse(SQLite already rolled back), and converts a failingROLLBACKinto a warning instead of letting it shadow the exception being handled. Applied to all three sites.UsageAuditWorker._flushnow always logs the traceback for flush failures.The store's asyncio lock is released and the worker loop keeps running in both cases, so after this fix a transient storage fault leaves behind the original error in the logs and the next batch succeeds on the same connection.
Testing
New
tests/observability/test_usage_audit_rollback_resilience.py(conftest-free):disk I/O error, notcannot rollbackin_transactionFalse afterwards)delete_user_datapathAll 4 tests fail on
main(they surfacecannot rollback - no transaction is active) and pass with this change; existing suites (test_usage_audit_store.py,test_usage_audit_worker.py,test_usage_audit_runtime.py) stay green (13 passed).Relation to #4303
This fixes the diagnostic-masking half of the incident: the reporter only ever saw the rollback error, never the underlying storage fault. The other halves are tracked in the cross-referenced chain: worker-liveness detection (#3542), manual recovery while wedged (#4627), orphaned-row hardening (#3989 / #4621), and the Python-side in-progress bookkeeping leak (#4745). A runtime (non-mount-time-only) stale sweep for QueueFS remains the open gap.
Closes #4303 (diagnostic half).