sqldb: wire up BusyTimeout config for SQLite store
What changed, and why it matters
This commit fixes a minor configuration bug in LND's SQLite database support. The software had a user-configurable 'busy timeout' setting, but it was being ignored and always set to 5000 milliseconds (5 seconds). The change makes the setting actually work, falling back to 5000 ms when not configured. This is a correctness/availability improvement, not a direct security vulnerability fix.
Treat as a routine bug fix. No urgent security action required. Users relying on SQLite may review their BusyTimeout setting if they experience database lock contention, as it now takes effect.
Security signals we found
Configuration option was silently ignored (functional bug)
No input validation changes, no injection vectors introduced
No cryptographic, authentication, or authorization changes
No vendor security framing in commit message or diff
Evidence from the diff
The SqliteConfig.BusyTimeout field was previously declared but unused. The SQLite DSN pragma busy_timeout was hardcoded to ‘5000’. The commit adds a busyTimeoutMs() helper that returns the configured duration in milliseconds or defaults to 5000 ms, and wires it into NewSqliteStore’s pragma list. This is a functional bug fix with potential availability implications under contention, but no evidence of a security flaw or exploit.
Changed components
sqldb/config.gosqldb/sqlite.goSQLite store initialization in lndInspect captured patch +17 / −1
diff --git a/sqldb/config.go b/sqldb/config.go
index 59801db..ebf386f 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 2b2f7be..fc724e9 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
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.