Skip to content

Commit dd44b40

Browse files
committed
lncfg: readd global lock for postgres and the channeldb_kv table
1 parent 911f729 commit dd44b40

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lncfg/db.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,18 +398,28 @@ func (db *DB) GetBackends(ctx context.Context, chanDBPath,
398398
// Convert the sqldb PostgresConfig to a kvdb postgres.Config.
399399
// This is a temporary measure until we migrate all kvdb SQL
400400
// users to native SQL.
401-
postgresConfig := GetPostgresConfigKVDB(db.Postgres)
401+
postgresConfigChannelDB := GetPostgresConfigKVDB(db.Postgres)
402+
403+
// The channel DB is still not robust enough to run with
404+
// multiple writers therefore we set the global lock for the
405+
// channel db in particular.
406+
//
407+
// TODO(ziggie): SHould be removed as soon as the revocation log
408+
// is migrated to native SQL.
409+
postgresConfigChannelDB.WithGlobalLock = true
402410

403411
postgresBackend, err := kvdb.Open(
404412
kvdb.PostgresBackendName, ctx,
405-
postgresConfig, NSChannelDB,
413+
postgresConfigChannelDB, NSChannelDB,
406414
)
407415
if err != nil {
408416
return nil, fmt.Errorf("error opening postgres graph "+
409417
"DB: %v", err)
410418
}
411419
closeFuncs[NSChannelDB] = postgresBackend.Close
412420

421+
postgresConfig := GetPostgresConfigKVDB(db.Postgres)
422+
413423
postgresMacaroonBackend, err := kvdb.Open(
414424
kvdb.PostgresBackendName, ctx,
415425
postgresConfig, NSMacaroonDB,

0 commit comments

Comments
 (0)