(
trx: DbTransaction,
opts?: { statementMs?: number; lockMs?: number; idleMs?: number }
)
| 20 | * and cleared at COMMIT/ROLLBACK before the session returns to the pool. |
| 21 | */ |
| 22 | export async function setTableTxTimeouts( |
| 23 | trx: DbTransaction, |
| 24 | opts?: { statementMs?: number; lockMs?: number; idleMs?: number } |
| 25 | ) { |
| 26 | const s = opts?.statementMs ?? 10_000 |
| 27 | const l = opts?.lockMs ?? 3_000 |
| 28 | const i = opts?.idleMs ?? 5_000 |
| 29 | await trx.execute(sql.raw(`SET LOCAL statement_timeout = '${s}ms'`)) |
| 30 | await trx.execute(sql.raw(`SET LOCAL lock_timeout = '${l}ms'`)) |
| 31 | await trx.execute(sql.raw(`SET LOCAL idle_in_transaction_session_timeout = '${i}ms'`)) |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Scales `statement_timeout` to the expected row-count work. |
no test coverage detected