Skip to content

fix(store): apply busy_timeout on every SQLite connection - #649

Merged
caigee-cmd merged 1 commit into
caigee-cmd:mainfrom
guyu233:fix/sqlite-dsn-pragmas
Dec 4, 2026
Merged

caigee-cmd merged 1 commit into
caigee-cmd:mainfrom
guyu233:fix/sqlite-dsn-pragmas

Conversation

@guyu233

@guyu233 guyu233 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Problem

busy_timeout is a per-connection SQLite pragma. It was applied once through db.Exec after opening the pool, which only configured the connection that Exec happened to take. Any later connection (after an idle recycle or a connection-level error) started with the default timeout, so concurrent writers could get SQLITE_BUSY immediately instead of waiting.

Change

Carry _busy_timeout=5000 in the DSN next to the existing _foreign_keys=on, so the driver applies both at open time on every pooled connection. The one-shot PRAGMA busy_timeout Exec is removed.

Validation

  • go build ./internal/store/...
  • go test ./internal/store/... -count=1
  • git diff --check

busy_timeout is per-connection. Setting it once through db.Exec only configured whichever pooled connection that Exec happened to take; after an idle recycle or a connection-level error, lock contention returned SQLITE_BUSY immediately. Carry it in the DSN next to foreign_keys so the driver applies it at open time on every connection.
@caigee-cmd
caigee-cmd merged commit 075f542 into caigee-cmd:main Dec 4, 2026
6 checks passed
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