Migration lock safety + remove the merge's full-table scan (the real 0040-hang fix) #85
Reference in New Issue
Block a user
Delete Branch "dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Root-cause fix for the migration hang + tag-standardization timeout. CI green (run #271,
e90e6b2).The real cause (operator-diagnosed)
Web has always been a single replica — there was no migration race. 0040's
ALTER series_pagehung because a concurrent tag merge had lockedseries_pageand was then stuck for minutes in_create_protective_aliases, an unindexed full scan ofimage_record(tagger_predictionsJSON, ~59k rows). The same scan starved the tag-standardization task into its 40-min timeout. One slow query, holding a lock inside a merge, blocked both.Fixes
perf(tags)— drop the scan (e90e6b2). The tagger'stag_to_categorymap is one-to-one, and a tag'skindis set from that category when created — sokindalready is the tagger's category for the name. The scan only ever rediscovered the kind. The merge now builds the protective alias fromsrc_kinddirectly: no scan, no lock-holding slow step. This removes the actual blocker (fixes both symptoms at the source).fix(alembic)— lock_timeout, drop advisory lock (8e98e79). Setslock_timeout(default 30s,MIGRATION_LOCK_TIMEOUToverride) on the migration connection — a blocked DDL now fails fast with "canceling statement due to lock timeout" and the entrypoint exits non-zero so the deploy surfaces it / retries, instead of hanging forever. Reverts thepg_advisory_xact_lock(it treated a race that wasn't the cause and added a new indefinite-hang mode).No schema change (alembic head stays 0042).
🤖 Generated with Claude Code