Release bookkeeping migration: take the files locks first
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:
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)`)
|
||||
|
||||
|
||||
Reference in new issue
Block a user