1.3 KiB
[Reviewed]
ADR-0013: PostgreSQL client boundary
Status
Superseded for M7.2 by ADR-0059, which adopts direct libpq for bounded asynchronous I/O. Historical recommendation follows.
Context
Persistence needs transactions, fencing, migrations and outbox; ticks must not call the database.
Decision
Recommend libpqxx inside persistence adapters, I/O-executor connection ownership and typed errors. Prototype rollback, parameterized SQL, deadlines, ambiguous reconnect and bounded pools.
Alternatives Considered
Direct libpq offers C ABI/async control with more RAII/result conversion. ORM introduces unneeded mapping. libpqxx adds C++ transaction ergonomics and exception translation.
Benefits
Transactional concerns isolated from biology.
Costs
Client/runtime deployment, pinning, pooling and integration tests.
Risks
Ambiguous commit, blocked requests, injection, retry duplication and schema mismatch.
Consequences
Parameterized SQL; unique constraints/idempotency for retries. Timeout does not prove rollback. Inject failure after commit before ACK. Pin supported PostgreSQL/libpqxx pair and measure throughput/size. libpqxx BSD-3-Clause, libpq.