multi: add --db.sync-graph-cache-load option
What changed, and why it matters
This commit adds a new optional command-line/configuration flag called --db.sync-graph-cache-load to the LND Lightning node software. It lets node operators choose to load the channel graph cache synchronously (blocking startup until complete) instead of the new default asynchronous loading. The change is purely an opt-out configuration addition and does not fix any vulnerability or change default behavior.
No security action required. This is a feature/operational toggle. Operators may use it as a workaround if they experience correctness or stability issues with async graph cache loading.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces a new boolean DB config option SyncGraphCacheLoad, wired through DefaultDatabaseBuilder.BuildDatabase to graphdb.WithAsyncGraphCachePopulation(!cfg.DB.SyncGraphCacheLoad). When set, it disables async population of the in-memory channel graph cache, forcing blocking/synchronous population at startup. The default remains false, preserving existing async behavior. No logic changes to graph cache implementation are present.
Changed components
lnd configuration (lncfg/db.go)database builder (config_builder.go)sample configuration file (sample-lnd.conf)Inspect captured patch +11 / −0
diff --git a/config_builder.go b/config_builder.go
index 647d265..0f563d6 100644
--- a/config_builder.go
+++ b/config_builder.go
@@ -1056,6 +1056,9 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
chanGraphOpts := []graphdb.ChanGraphOption{
graphdb.WithUseGraphCache(!cfg.DB.NoGraphCache),
+ graphdb.WithAsyncGraphCachePopulation(
+ !cfg.DB.SyncGraphCacheLoad,
+ ),
}
// We want to pre-allocate the channel graph cache according to what we
diff --git a/lncfg/db.go b/lncfg/db.go
index 6835382..4a8680b 100644
--- a/lncfg/db.go
+++ b/lncfg/db.go
@@ -89,6 +89,8 @@ type DB struct {
NoGraphCache bool `long:"no-graph-cache" description:"Don't use the in-memory graph cache for path finding. Much slower but uses less RAM. Can only be used with a bolt database backend."`
+ SyncGraphCacheLoad bool `long:"sync-graph-cache-load" description:"Force synchronous loading of the graph cache. This will block the startup until the graph cache is fully loaded into memory. This is useful if any bugs appear with the new async loading feature of the graph cache."`
+
PruneRevocation bool `long:"prune-revocation" description:"Run the optional migration that prunes the revocation logs to save disk space."`
NoRevLogAmtData bool `long:"no-rev-log-amt-data" description:"If set, the to-local and to-remote output amounts of revoked commitment transactions will not be stored in the revocation log. Note that once this data is lost, a watchtower client will not be able to back up the revoked state."`
diff --git a/sample-lnd.conf b/sample-lnd.conf
index f874fad..6f3d849 100644
--- a/sample-lnd.conf
+++ b/sample-lnd.conf
@@ -1501,6 +1501,12 @@
; less RAM. Can only be used with a bolt database backend.
; db.no-graph-cache=false
+; Block the start-up of LND until the graph cache has been fully populated.
+; If not set, the graph cache will be populated asynchronously and any read
+; calls made before the cache is fully populated will fall back to the
+; database.
+; db.sync-graph-cache-load=false
+
; Specify whether the optional migration for pruning old revocation logs
; should be applied. This migration will only save disk space if there are open
; channels prior to lnd@v0.15.0.
Why this scored 12/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.