sqldb: add global lock config options for postgres
What changed, and why it matters
This commit adds two new configuration options for LND's Postgres database backends that let operators choose whether to use a single global lock for channel database and wallet database access. The defaults are chosen to preserve existing behavior: channeldb does not use the global lock, while walletdb does. The commit describes this as a temporary workaround until those subsystems are migrated to native SQL. There is no direct security fix here; it is a configurability change that may help operators avoid concurrency-related bugs or data corruption, but it does not by itself patch a known vulnerability.
Treat this as a routine configurability improvement rather than a security patch. Operators using Postgres should review the new options and defaults to ensure they match expected concurrency behavior. Monitor follow-up commits that actually implement or change the global-lock logic, and watch for future disclosures about concurrency issues in the revocation log or wallet SQL migration.
Security signals we found
Concurrency-safety workaround exposed as configuration option
Global lock reduces concurrency to prevent potential race conditions or data corruption
Commit explicitly frames change as temporary until native SQL migration
No vulnerability description, CVE, or security advisory present in commit or references
Evidence from the diff
The diff modifies sqldb/config.go to add two boolean fields to PostgresConfig: ChannelDBWithGlobalLock (default false) and WalletDBWithGlobalLock (default true). These expose previously hardcoded global-lock behavior as user-configurable options. The commit message states this is a temporary measure until the revocation log and wallet are migrated to native SQL and become fully concurrent-safe. The change is purely additive configuration plumbing; no locking logic is changed in this commit.
Changed components
sqldb/config.goPostgresConfig structLND Postgres database backend configurationInspect captured patch +7 / −5
diff --git a/sqldb/config.go b/sqldb/config.go
index 34de293..59801db 100644
--- a/sqldb/config.go
+++ b/sqldb/config.go
@@ -44,11 +44,13 @@ func (p *SqliteConfig) Validate() error {
//
//nolint:ll
type PostgresConfig struct {
- Dsn string `long:"dsn" description:"Database connection string."`
- Timeout time.Duration `long:"timeout" description:"Database connection timeout. Set to zero to disable."`
- MaxConnections int `long:"maxconnections" description:"The maximum number of open connections to the database. Set to zero for unlimited."`
- SkipMigrations bool `long:"skipmigrations" description:"Skip applying migrations on startup."`
- QueryConfig `group:"query" namespace:"query"`
+ Dsn string `long:"dsn" description:"Database connection string."`
+ Timeout time.Duration `long:"timeout" description:"Database connection timeout. Set to zero to disable."`
+ MaxConnections int `long:"maxconnections" description:"The maximum number of open connections to the database. Set to zero for unlimited."`
+ SkipMigrations bool `long:"skipmigrations" description:"Skip applying migrations on startup."`
+ ChannelDBWithGlobalLock bool `long:"channeldb-with-global-lock" description:"Use a global lock for channeldb access. This ensures only a single writer at a time but reduces concurrency. This is a temporary workaround until the revocation log is migrated to a native sql schema."`
+ WalletDBWithGlobalLock bool `long:"walletdb-with-global-lock" description:"Use a global lock for wallet database access. This ensures only a single writer at a time but reduces concurrency. This is a temporary workaround until the wallet subsystem is upgraded to a native sql schema."`
+ QueryConfig `group:"query" namespace:"query"`
}
// Validate checks that the PostgresConfig values are valid.
Why this scored 23/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.