Skip to content

Pool acquire deadline, pool-sharing auxiliary stores, migration advisory locks - #7

Merged
codeitlikemiley merged 3 commits into
mainfrom
pool-deadline-shared-aux-stores
Aug 23, 2026
Merged

Pool acquire deadline, pool-sharing auxiliary stores, migration advisory locks#7
codeitlikemiley merged 3 commits into
mainfrom
pool-deadline-shared-aux-stores

Conversation

@hexuria

@hexuria hexuria commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Next batch from the repo review (items #6 and #8), plus a pre-existing concurrency bug the new live tests exposed.

Changes

  • Pool acquire deadlineConnectionPool::acquire waited forever on an exhausted pool. It now fails after 30s with a connection error naming the lease count (N of M connections leased), so saturation is diagnosable instead of a hang. Regression test via a test-only timeout override.
  • Pool-sharing auxiliary storesPostgres/MySql{Checkpoint,Idempotency,Snapshot}Store each held a dedicated Arc<Mutex<connection>>. They now run on ConnectionPool internally (existing constructors keep identical single-connection behaviour via ConnectionPool::single), and the event stores gained checkpoint_store(), idempotency_store(), snapshot_store() accessors (+ _with_table_name variants) that share the event store's pool — one pooled connection set for the whole store family. Reads go through pool.read (stale-connection retry), writes through pool.write.
  • Migration advisory locks — concurrent initialize_schema runs raced on CREATE TABLE IF NOT EXISTS and the applied-migrations bookkeeping. Against a fresh database this reliably failed parallel live tests — on main too (4 failures), so it's pre-existing, surfaced by the new tests. run_postgres now wraps the pass in pg_advisory_lock, run_mysql in GET_LOCK; SQLite unchanged (already serialized per store).

Verification

  • New env-gated live tests run the checkpoint/idempotency/snapshot contracts through the pool-sharing accessors on both backends (test_postgres_pool_sharing_auxiliary_stores, test_mysql_pool_sharing_auxiliary_stores)
  • Full suite run against disposable Postgres 17 + MySQL 8 containers: 3 consecutive fully-parallel runs against freshly wiped databases, all green (previously failed every fresh-DB run, on main as well)
  • clippy --all-targets --all-features -D warnings, 47 lib + 67 framework + 28 doc tests green offline

https://claude.ai/code/session_01Wq5AdnNWVKWRTS34g6A3Bu

…orever

An exhausted pool (or a leaked lease) previously blocked every caller
indefinitely in acquire's wait loop. Acquisition now waits at most 30
seconds and then fails with a connection error naming the lease count,
so saturation surfaces as a diagnosable error instead of a hang.

Claude-Session: https://claude.ai/code/session_01Wq5AdnNWVKWRTS34g6A3Bu
… snapshot stores

The Postgres and MySQL auxiliary stores each held a dedicated
Arc<Mutex<connection>> - one serialized connection apiece, separate
from the event store's pool. They now run on ConnectionPool internally
(constructed from ConnectionPool::single for the existing constructors,
preserving behaviour), and the event stores expose checkpoint_store,
idempotency_store, and snapshot_store accessors (plus _with_table_name
variants) that share the event store's pool, so one pooled connection
set serves the whole store family.

Live-DB tests (env-gated) run the checkpoint, idempotency, and snapshot
contracts through the pool-sharing accessors on both backends.

Claude-Session: https://claude.ai/code/session_01Wq5AdnNWVKWRTS34g6A3Bu
Concurrent migration runs (multiple stores initializing schemas at
once) raced on CREATE TABLE IF NOT EXISTS and the applied-migrations
bookkeeping; on a fresh database this reliably failed parallel live
tests with Postgres pg_type unique violations, on main as well as this
branch. run_postgres now holds pg_advisory_lock and run_mysql GET_LOCK
for the whole migration pass. SQLite is unchanged: its per-store
connection is already serialized behind a mutex.

Verified with three consecutive fully parallel test-suite runs against
freshly wiped Postgres and MySQL containers.

Claude-Session: https://claude.ai/code/session_01Wq5AdnNWVKWRTS34g6A3Bu
@codeitlikemiley
codeitlikemiley merged commit 5b4c546 into main Aug 23, 2026
1 check passed
@codeitlikemiley
codeitlikemiley deleted the pool-deadline-shared-aux-stores branch August 23, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants