Centralize SQLite connection configuration (#33938)

## What changed

- Add `SqliteConfig` as the shared entry point for read-write and read-only SQLite pools.
- Apply consistent WAL, synchronization, auto-vacuum, busy-timeout, logging, and pool-size settings to writable Codex databases.
- Route state runtime, audit, CLI, and test database connections through the shared configuration.

## Testing

- Run migration tests against temporary on-disk databases opened through `SqliteConfig`, including the concurrent-writer repair case.

GitOrigin-RevId: e3946b98bde04c47574532ac8b1a7bb2b03edd97
This commit is contained in:
Adam Perry @ OpenAI
2026-07-18 02:06:13 +00:00
committed by copyberry
parent 23899f7cb6
commit 6bd3f5e3db
14 changed files with 220 additions and 166 deletions
+5 -10
View File
@@ -727,8 +727,6 @@ mod tests {
use super::*;
use codex_protocol::ThreadId;
use pretty_assertions::assert_eq;
use sqlx::sqlite::SqliteConnectOptions;
use sqlx::sqlite::SqlitePoolOptions;
use tempfile::TempDir;
#[tokio::test]
@@ -1152,14 +1150,11 @@ mod tests {
async fn insert_thread_row(&self, id: &str, rollout_path: &Path, archived: bool) {
let state_db_path = codex_state::state_db_path(self.sqlite_home.path());
let options = SqliteConnectOptions::new()
.filename(state_db_path)
.create_if_missing(false);
let pool = SqlitePoolOptions::new()
.max_connections(1)
.connect_with(options)
.await
.expect("sqlite pool");
let pool =
codex_state::SqliteConfig::new_for_testing(self.sqlite_home.path().to_path_buf())
.open_read_write_pool(&state_db_path)
.await
.expect("sqlite pool");
sqlx::query(
r#"
INSERT INTO threads (