Release bookkeeping migration: take the files locks first
Test and deploy / test (push) Successful in 1m19s
Test and deploy / deploy (push) Successful in 2m6s

The trigger swap deadlocked with ingest on homelab (DROP TRIGGER locks
the partitions one by one); LOCK TABLE up front cannot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daan MeijerandClaude Opus 5.5 committed 2026-10-06 13:53:52 +02:00
1 parent be2112f4ad
commit 61b683a71f
1 file changed
+4 -1
@@ -22,8 +22,11 @@ import { BaseSchema } from '@adonisjs/lucid/schema'
export default class extends BaseSchema {
async up() {
const q = (sql: string) => this.db.rawQuery(sql)
// Swapping triggers locks files and its partitions: give up rather than queue every writer behind it.
// Swapping triggers locks files and its partitions. Taken first and in one statement: a
// DROP TRIGGER later in the transaction deadlocked with ingest (2026-10-06). Give up rather
// than queue every writer behind it for long.
await q(`SET LOCAL lock_timeout = '2min'`)
await q(`LOCK TABLE files, release_files IN ACCESS EXCLUSIVE MODE`)
// Built CONCURRENTLY by hand on homelab (2026-10-06); IF NOT EXISTS keeps that one.
await q(`CREATE INDEX IF NOT EXISTS release_files_release_size_idx ON release_files (release_id, size)`)