pog.transaction checkout uses hardcoded 5s timeout, ignoring pool config
- Dominant language
- Gleam
- Stars
- 264
- Forks
- 35
- PR merge metrics
- No merged PRs in 30d
Description
## Problem
`pog.transaction` calls `pgo:checkout(Name)` with no timeout option, which defaults to pgo_pool's hardcoded `?TIMEOUT` of 5000ms:
```erlang
% pog_ffi.erl line 113
checkout(Name) when is_atom(Name) ->
case pgo:checkout(Name) of %% <-- no timeout passed
```
Meanwhile, `pog.query` passes the timeout correctly:
```erlang
% pog_ffi.erl line 90-94
Options = #{
pool => Name,
pool_options => [{timeout, Timeout}] %% <-- timeout passed
},
pgo:query(Sql, Arguments, Options)
```
This means `queue_target` and `queue_interval` pool config have no effect on transaction checkout. Any serverless database (Neon, Supabase) with >5s cold starts, or cross-region connections with high latency, will hit `TransactionQueryError(QueryTimeout)` on transactions while regular queries work fine.
## Reproduction
```gleam
// This works — timeout is passed through to pgo:query
pog.query("SELECT 1")
|> pog.timeout(30_000)
|> pog.execute(db)
// This fails with QueryTimeout after exactly 5s — timeout is not configurable
pog.transaction(db, fn(tx) {
// ... any queries ...
})
```
## Suggested fix
Pass a configurable timeout to `pgo:checkout/2` in the transaction path:
```erlang
checkout(Name, Timeout) when is_atom(Name) ->
case pgo:checkout(Name, [{timeout, Timeout}]) of
{ok, Ref, Conn} -> {ok, {Ref, Conn}};
{error, Error} -> {error, convert_error(Error)}
end.
```
And expose it in the Gleam API, perhaps as a second argument to `pog.transaction` or via the pool config.
## Context
Discovered while deploying a Gleam/wisp app on connecting to a distant PostgreSQL. Regular queries worked, but transactions with multiple round-trips exceeded the 5s hardcoded limit.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in pog_ffi.erl around lines 90-113 and compare the timeout handling in pog.query with the transaction checkout path. Review the pgo:checkout API and the Gleam transaction API before choosing how the timeout should be exposed. Done means transaction checkout uses the configured timeout instead of the fixed 5-second default, while the reproduction no longer fails at exactly 5 seconds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- erlang, postgresql
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100