Skip to content

Connection pool has no acquire timeout, liveness check, idle eviction or max lifetime #562

Description

@Yaraslaut

DataMapper/Pool.hpp has a more sophisticated waiter model than any C++ peer — a single FIFO shared between sync and async waiters, three growth strategies selected at compile time — but none of the operational controls that keep a pool healthy in production.

Missing

Control Status Evidence
Acquire timeout absent Pool.hpp:269node->cv.wait(lock, pred), no wait_for. SqlBackup/ConnectionPool.cpp:46-53 — same. There is no wait_for/wait_until anywhere in src/Lightweight.
Validation on borrow absent SqlConnection::IsAlive() exists (SqlConnection.cpp:471) but no pool calls it
Idle eviction absent idle connections are held indefinitely
Max lifetime absent a connection is never proactively recycled
Retry on broken connection absent a dead connection is handed to the caller as-is

Consequences

  • A connection killed by a firewall idle timeout, a failover, or a server restart is handed to the next caller, which fails with a driver error the pool could have prevented.
  • An exhausted BoundedWait pool blocks the calling thread forever with no diagnostic.

Prior art

ormpp's much simpler pool does ping() on checkout and recycles at 8 hours (ormpp/connection_pool.hpp); HikariCP-class pools do all five.

Suggested scope

  1. Acquire(std::chrono::milliseconds timeout) returning std::expected<PooledDataMapper, PoolError> — pairs naturally with Add deadline propagation across queries, transactions, and retries #553 (deadline propagation).
  2. Optional validation-on-borrow using the existing IsAlive(), off by default for latency-sensitive callers.
  3. maxIdleTime / maxLifetime in PoolConfig.

Items 1 and 3 are PoolConfig additions, which is an NTTP, so they are source-compatible for existing users of the default config.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions