From 57fd965932af88ad9389fdf68bdcc41d71d41cb7 Mon Sep 17 00:00:00 2001 From: ziggie Date: Wed, 11 Feb 2026 12:40:05 +0100 Subject: [PATCH] sqldb: wire up BusyTimeout config for SQLite store MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The SqliteConfig.BusyTimeout field existed but was never used — the busy_timeout pragma was hardcoded to 5000ms. Add a busyTimeoutMs() helper that returns the configured value or falls back to the 5000ms default, and use it when constructing the SQLite DSN. --- sqldb/config.go | 16 ++++++++++++++++ sqldb/sqlite.go | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/sqldb/config.go b/sqldb/config.go index 59801dbea..ebf386f54 100644 --- a/sqldb/config.go +++ b/sqldb/config.go @@ -31,6 +31,22 @@ type SqliteConfig struct { QueryConfig `group:"query" namespace:"query"` } +const ( + // defaultBusyTimeoutMs is the default busy_timeout value in + // milliseconds, used when no BusyTimeout is configured. + defaultBusyTimeoutMs = 5000 +) + +// busyTimeoutMs returns the busy_timeout value in milliseconds. If +// BusyTimeout is not set, it returns the default value. +func (s *SqliteConfig) busyTimeoutMs() int64 { + if s.BusyTimeout > 0 { + return s.BusyTimeout.Milliseconds() + } + + return defaultBusyTimeoutMs +} + // Validate checks that the SqliteConfig values are valid. func (p *SqliteConfig) Validate() error { if err := p.QueryConfig.Validate(true); err != nil { diff --git a/sqldb/sqlite.go b/sqldb/sqlite.go index 2b2f7be13..fc724e939 100644 --- a/sqldb/sqlite.go +++ b/sqldb/sqlite.go @@ -70,7 +70,7 @@ func NewSqliteStore(cfg *SqliteConfig, dbPath string) (*SqliteStore, error) { }, { name: "busy_timeout", - value: "5000", + value: fmt.Sprintf("%d", cfg.busyTimeoutMs()), }, { // With the WAL mode, this ensures that we also do an