Skip to content

Commit edf5b80

Browse files
authored
fix(db): force max_connections=1 for in-memory SQLite pools (#2491)
Each physical connection to sqlite::memory: is a separate empty database. When the pool size is >1, queries routed to connections other than the one that ran migrations hit a schema-less DB and fail with "no such column: superseded_by". Capping max_connections at 1 for :memory: URLs ensures all queries share the same migrated schema. Fixes 91 failing graph tests introduced after migration 056 (superseded_by column) in PR #2465. Closes #2468
1 parent b447fa1 commit edf5b80

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
99
### Fixed
1010

1111
- fix(tools): agent now prefers `memory_search` over `search_code` when recalling user-provided facts — updated `search_code` description to exclude user facts/preferences; updated `memory_search` description to emphasise user-provided context recall; session-level hint injected into the volatile system prompt block when `memory_save` was called in the current session (closes #2475)
12+
- fix(db): in-memory SQLite pool forced to `max_connections = 1` so all queries share the same connection and the migrated schema — previously each additional connection in the pool opened a separate empty in-memory database, causing `no such column: superseded_by` in 91 graph tests after migration 056 was introduced (closes #2468)
1213

1314
### Added
1415

crates/zeph-db/src/pool.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ impl DbConfig {
7474

7575
// BEGIN IMMEDIATE serializes concurrent writers at the SQLite level.
7676
// pool_size controls the connection count; max_connections is the upper bound.
77-
let effective_max = max_connections.max(pool_size);
77+
// In-memory databases are connection-scoped: each new connection is a separate
78+
// empty DB. Force a single connection so all queries share the migrated schema.
79+
let effective_max = if path == ":memory:" {
80+
1
81+
} else {
82+
max_connections.max(pool_size)
83+
};
7884
let pool = SqlitePoolOptions::new()
7985
.max_connections(effective_max)
8086
.min_connections(1)

0 commit comments

Comments
 (0)