From 7e415d1aed52a5477fd0454c2bbb3c3a3c4d50f9 Mon Sep 17 00:00:00 2001 From: jonahgabriel Date: Tue, 28 Jul 2026 05:55:09 -0400 Subject: [PATCH] fix(OMN-15312): wrap delegation reconcile migration 0009a in an explicit transaction The forward-migration runner applies node migrations with psql -f in autocommit (no --single-transaction), so the SET LOCAL statements degraded to warnings and LOCK TABLE hard-errored with ERROR: LOCK TABLE can only be used in transaction blocks exiting 3 and aborting every cold-lane bring-up (OMN-13414 path), which is the only documented recovery for the GC-reclaimed dev lane (OMN-15190). While that lane is down, occ-autobind/occ-companion-effect publishes fail org-wide against omninode-pc:19092 and cascade into the Receipt Gate. Wrapping the body in BEGIN/COMMIT also supplies the atomicity the file header already claims (retry without leaving a partial conversion), which did not exist under autocommit. No other node migration uses BEGIN; this file was the sole one relying on a transaction context the runner never provided. Proven RED then GREEN against a cold omnidash_analytics on the .201 dev lane: RED exit 3 (LOCK TABLE ...), GREEN exit 0, and a second apply exit 0 (idempotent). --- .../0009a_delegation_events_legacy_schema_reconcile.sql | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/omnimarket/nodes/node_projection_delegation/migrations/0009a_delegation_events_legacy_schema_reconcile.sql b/src/omnimarket/nodes/node_projection_delegation/migrations/0009a_delegation_events_legacy_schema_reconcile.sql index 4a85d8faf6..c666140154 100644 --- a/src/omnimarket/nodes/node_projection_delegation/migrations/0009a_delegation_events_legacy_schema_reconcile.sql +++ b/src/omnimarket/nodes/node_projection_delegation/migrations/0009a_delegation_events_legacy_schema_reconcile.sql @@ -8,6 +8,13 @@ -- partial conversion. The staging table was measured at 6 rows / 128 kB before -- rollout, so the in-place JSONB-to-integer rewrite is deliberately preferred -- over a permanent dual-column compatibility path. +-- The runner (scripts/run-forward-migrations.sh) applies node migrations with +-- `psql -f` in autocommit, one statement per implicit transaction. The SET LOCAL +-- scoping and the LOCK TABLE below are only legal inside an explicit transaction +-- block, and the partial-conversion guarantee described above requires one, so +-- this migration opens its own (OMN-15312). +BEGIN; + SET LOCAL lock_timeout = '5s'; SET LOCAL statement_timeout = '2min'; LOCK TABLE delegation_events IN ACCESS EXCLUSIVE MODE; @@ -173,3 +180,5 @@ BEGIN ALTER COLUMN quality_gates_failed SET NOT NULL; END $reconcile_failed$; + +COMMIT;