Bound SQLite integrity checks for diagnostic attachments (#40688)

## Why

Diagnostic uploads skip the doctor attachment if report generation exceeds its
overall timeout. SQLite integrity scans can be delayed by large databases or
lock contention.

## What changed

- Give each database integrity scan a one-second deadline when collecting a
  diagnostic attachment.
- Interrupt scans and lock waits at the deadline, preserve any corruption rows
  already returned, and report an incomplete clean scan as a warning.
- Keep direct `codex doctor` integrity checks unbounded.

## Testing

- Cover interrupted scans, lock waits, retries without a deadline, and
  corruption results returned before interruption.

GitOrigin-RevId: 4817fb459ac53953669a9ba5f03397a6fc82c72e
This commit is contained in:
chess
2026-08-25 20:09:55 +00:00
committed by copyberry
parent 94967e03e5
commit 32ce703a80
7 changed files with 194 additions and 53 deletions
+9 -2
View File
@@ -291,12 +291,19 @@ impl SqliteConfig {
}
/// Open an existing Codex SQLite database without creating or modifying it.
pub async fn open_read_only_pool(&self, path: &Path) -> Result<SqlitePool, Error> {
let options = SqliteConnectOptions::new()
pub async fn open_read_only_pool(
&self,
path: &Path,
busy_timeout: Option<Duration>,
) -> Result<SqlitePool, Error> {
let mut options = SqliteConnectOptions::new()
.filename(path)
.create_if_missing(false)
.read_only(true)
.log_statements(LevelFilter::Off);
if let Some(busy_timeout) = busy_timeout {
options = options.busy_timeout(busy_timeout);
}
SqlitePoolOptions::new()
.max_connections(1)
.connect_with(options)