Files
accounted/tests/pg/sie-rpc-statement-timeout.pg.test.ts
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

43 lines
1.6 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { getPool } from './setup'
/**
* The SIE import/replace/undo RPCs each run an entire file's work in one
* statement, so each carries a function-scoped statement_timeout (migrations
* 20260629160100 and 20260721144311); without it they inherit the 8s
* authenticator timeout and any real-world multi-year migration is cancelled
* with "canceling statement due to statement timeout".
*
* CREATE OR REPLACE FUNCTION silently drops settings attached via
* ALTER FUNCTION ... SET, so a future redefinition of any of these functions
* would revive the bug unless the SET is carried along. This ratchet runs
* after full migration replay in CI and pins the config.
*/
const TIMEOUT_PROTECTED_FUNCTIONS = [
'import_sie_journal_entries',
'replace_sie_import',
'undo_sie_import',
]
describe('SIE RPC statement_timeout config', () => {
it.each(TIMEOUT_PROTECTED_FUNCTIONS)(
'%s carries a function-scoped statement_timeout of 290s',
async (functionName) => {
const { rows } = await getPool().query<{ proconfig: string[] | null }>(
`SELECT p.proconfig
FROM pg_proc p
JOIN pg_namespace n ON n.oid = p.pronamespace
WHERE n.nspname = 'public' AND p.proname = $1`,
[functionName],
)
expect(rows, `${functionName} should exist exactly once in public`).toHaveLength(1)
expect(
rows[0].proconfig ?? [],
`${functionName} lost its statement_timeout: re-add "SET statement_timeout = '290s'" ` +
'to the CREATE OR REPLACE FUNCTION statement that redefined it',
).toContain('statement_timeout=290s')
},
)
})