aa6d42a167
A production Fortnox migration failed with "SIE-verifikationer kunde inte importeras atomiskt: canceling statement due to statement timeout": the atomic import RPC (20260712150000) inherits the 8s authenticator statement_timeout, so any real-world multi-year SIE file exceeds it and the whole import is cancelled and rolled back. Same failure class as 20260629160100 (replace_sie_import / undo_sie_import); same fix, a function-scoped statement_timeout of 290s sitting under the calling routes' maxDuration = 300 ceiling. Migration 20260721144311 is already applied to prod (proconfig verified carrying statement_timeout=290s); the committed file is byte-identical under the same version. The new pg-real ratchet pins the config on all three SIE RPCs because CREATE OR REPLACE FUNCTION silently drops ALTER FUNCTION settings. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
23 lines
1.2 KiB
SQL
23 lines
1.2 KiB
SQL
-- Raise statement_timeout inside the atomic SIE import RPC so a large
|
|
-- Fortnox/provider migration is not cancelled mid-import.
|
|
--
|
|
-- Same failure class and fix as 20260629160100 (replace_sie_import /
|
|
-- undo_sie_import): a PostgREST request runs under the authenticator
|
|
-- role's 8s statement_timeout, and import_sie_journal_entries commits an
|
|
-- entire SIE file in one call (per-voucher loop, per-line inserts, audit
|
|
-- triggers). A real-world multi-year migration (thousands of vouchers)
|
|
-- exceeds 8s, the statement is cancelled ("canceling statement due to
|
|
-- statement timeout"), and the whole import rolls back with
|
|
-- "SIE-verifikationer kunde inte importeras atomiskt".
|
|
--
|
|
-- A function-scoped SET re-arms the timer for the duration of the call and
|
|
-- is restored on exit. 290s sits just under the calling routes' maxDuration
|
|
-- = 300 ceiling (/api/extensions/ext/[...path], /api/import/sie/execute,
|
|
-- /api/v1/.../imports/sie), so the serverless layer stays the effective
|
|
-- bound. Function body is unchanged; only configuration is altered.
|
|
|
|
ALTER FUNCTION public.import_sie_journal_entries(uuid, uuid, uuid, jsonb)
|
|
SET statement_timeout = '290s';
|
|
|
|
NOTIFY pgrst, 'reload schema';
|