Skip to content

fix(transcribe): open a fresh DB connection per job transition#189

Merged
robbiebyrd merged 1 commit into
mainfrom
fix/transcribe-idle-timeout
Jul 10, 2026
Merged

fix(transcribe): open a fresh DB connection per job transition#189
robbiebyrd merged 1 commit into
mainfrom
fix/transcribe-idle-timeout

Conversation

@robbiebyrd

Copy link
Copy Markdown
Collaborator

Problem

Every transcribe-item run since 2026-07-09 fails with PendingRollbackError (186 failed runs). Root cause chain:

  1. rt911-db sets idle_session_timeout=10min on the video_grabber database (added during the 2026-07-08 connection-leak firefight).
  2. transcribe_item_flow opened one DB connection and held it idle for the 15–20 minutes whisper takes, so Postgres killed it before the final stage='done' UPDATE (server closed the connection unexpectedly).
  3. The except path then reused the same invalidated connection → PendingRollbackError, so the job was never marked done or failed — it stayed in transcribing, the supervisor reclaimed it, and the GPU re-transcribed the same programs in a loop (the SRT/VTT uploads actually succeed; only the bookkeeping write dies).

Fix

transition_transcribe_job now opens its own fresh, short-lived connection per transition instead of taking a held one, so no connection ever idles across transcription. The idle_session_timeout leak backstop stays in place.

Regression tests simulate the production failure: every connection opened before transcribe_wav is killed mid-transcription, and the flow must still record done (and failed on error) on fresh connections.

Also: unblock red CI on main

test_identifier_prefix_fallback_for_international_feed has been failing on main since 3be9c05 (CCTV3→CCTV4 rename) — the test landed but the CCTV3_ identifier-prefix alias didn't, which also blocked image builds. Added "cctv3": "cctv4" to KNOWN_CHANNELS.

Verification

  • pytest tests/ — 303 passed, 8 skipped (only the documented live-Postgres test_migrations errors locally)
  • ruff check video_grabber/ tests/ — clean

Note: process-item and the usenet flows still hold a connection across long stages (a multi-GB IA download can idle >10min) — same latent bug class, follow-up candidate.

🤖 Generated with Claude Code

rt911-db sets idle_session_timeout=10min on the video_grabber database
(leak protection added 2026-07-08), but whisper keeps transcribe-item
busy for 15-20 minutes. The flow held one connection across the whole
run, so it was dead by the final stage='done' UPDATE — and the failure
path reused the same poisoned connection, raising PendingRollbackError
and leaving the job stuck in 'transcribing' for the supervisor to
reclaim and re-transcribe forever (186 failed runs since 2026-07-09).

transition_transcribe_job now opens its own short-lived connection, so
no connection ever idles across transcription.

Also alias the CCTV3_ identifier prefix to the cctv4 slug — the test
expecting it landed in 3be9c05 without the mapping, leaving CI on main
red and blocking image builds.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Playwright E2E — 1 passed · 0 failed · 0 flaky · 0 skipped

Full report

@robbiebyrd robbiebyrd merged commit 232dbbb into main Jul 10, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant