ADR-0042 — The savers take a pool, not a connection, a pipeline or a sync pool
- Status: Accepted
- Date: 2026-12-05
- Supersedes: none
- Authors: project maintainers
Context
Upstream's AsyncPostgresSaver takes an AsyncConnection or an AsyncConnectionPool, with an
optional pipe on a single connection, and its PostgresSaver takes a Connection or a
ConnectionPool (langgraph/checkpoint/postgres/aio.py and __init__.py in
langgraph-checkpoint-postgres 3.2.0). An adopter who swaps the class name keeps upstream's
arguments.
AsyncOpenPostgresCheckpointer takes only an AsyncConnectionPool,
and OpenPostgresCheckpointer is made only by from_conn_string
(architecture.md §9). Neither choice was recorded, and the async
constructor checked nothing: given a connection it was built, and failed on the first operation.
Decision
The async saver takes an AsyncConnectionPool and raises TypeError at construction for an
AsyncConnection. The sync saver is made only by from_conn_string. Neither takes a pipe. We will not add
upstream's other constructor shapes.
Alternatives considered
- Take a single
AsyncConnection— rejected: operations on one connection cannot overlap, and several of ours open a transaction (aio.py,conn.transaction()), so it needs upstream's saver-wideasyncio.Lock, whose absence is this saver's concurrency result (ADR-0035).from_conn_string(conn_string, max_size=1)gives one connection through the same code path. - Take a
pipe— rejected: a pipeline batches upstream's several statements peraput; ours is one statement, and upstream itself refuses a pipeline on a pool. - Take a sync
ConnectionPoolin the sync saver — rejected: the sync saver drives the async one on its own loop, which cannot use a sync pool, so it means a second implementation and a second conformance tier. - Refuse everything that is not an
AsyncConnectionPool— rejected: it breaks pool stand-ins in callers' unit tests to guard against arguments nobody has a reason to pass. - Leave the constructor unchecked — rejected: the first operation failed with an error that named neither the cause nor the fix.
Consequences
- An adopter passing upstream's connection gets a
TypeErrorthat names the pool and the single-connection alternative, before any thread or query starts. - A sync application that owns a
ConnectionPoolcannot share it with the sync saver; the saver opens its own pool, so the application holds connections in two pools. - Only an
AsyncConnectionis refused: a test double standing in for the pool still constructs, as this repository's own unit tests do.
References
src/open_postgres_checkpointer/aio.py(AsyncOpenPostgresCheckpointer.__init__)tests/integration/test_setup_and_pool.py- Compatibility promise