From 1ccc5e80147fb5ef5dc508be8abbeae28fa92c54 Mon Sep 17 00:00:00 2001 From: Andras Banki-Horvath Date: Thu, 2 Dec 2021 20:55:05 +0100 Subject: [PATCH] etcd: make max message size configurable --- go.mod | 2 +- kvdb/etcd/config.go | 2 ++ kvdb/etcd/db.go | 2 +- lncfg/db.go | 4 ++++ sample-lnd.conf | 3 +++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index e90c29a17..e50737815 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,7 @@ require ( github.com/lightningnetwork/lnd/cert v1.1.0 github.com/lightningnetwork/lnd/clock v1.1.0 github.com/lightningnetwork/lnd/healthcheck v1.2.0 - github.com/lightningnetwork/lnd/kvdb v1.2.1 + github.com/lightningnetwork/lnd/kvdb v1.2.3 github.com/lightningnetwork/lnd/queue v1.1.0 github.com/lightningnetwork/lnd/ticker v1.1.0 github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 diff --git a/kvdb/etcd/config.go b/kvdb/etcd/config.go index 8798bcb60..6d060e895 100644 --- a/kvdb/etcd/config.go +++ b/kvdb/etcd/config.go @@ -30,6 +30,8 @@ type Config struct { CollectStats bool `long:"collect_stats" description:"Whether to collect etcd commit stats."` + MaxMsgSize int `long:"max_msg_size" description:"The maximum message size in bytes that we may send to etcd."` + // SingleWriter should be set to true if we intend to only allow a // single writer to the database at a time. SingleWriter bool diff --git a/kvdb/etcd/db.go b/kvdb/etcd/db.go index 315359ecd..119816c85 100644 --- a/kvdb/etcd/db.go +++ b/kvdb/etcd/db.go @@ -141,7 +141,7 @@ func newEtcdBackend(ctx context.Context, cfg Config) (*db, error) { DialTimeout: etcdConnectionTimeout, Username: cfg.User, Password: cfg.Pass, - MaxCallSendMsgSize: 16384*1024 - 1, + MaxCallSendMsgSize: cfg.MaxMsgSize, } if !cfg.DisableTLS { diff --git a/lncfg/db.go b/lncfg/db.go index 8022a8467..34c7f2137 100644 --- a/lncfg/db.go +++ b/lncfg/db.go @@ -73,6 +73,10 @@ func DefaultDB() *DB { AutoCompactMinAge: kvdb.DefaultBoltAutoCompactMinAge, DBTimeout: kvdb.DefaultDBTimeout, }, + Etcd: &etcd.Config{ + // Allow at most 32 MiB messages by default. + MaxMsgSize: 32768 * 1024, + }, Postgres: &postgres.Config{ MaxConnections: defaultPostgresMaxConnections, }, diff --git a/sample-lnd.conf b/sample-lnd.conf index d42831ce7..36b1e4bb0 100644 --- a/sample-lnd.conf +++ b/sample-lnd.conf @@ -1169,6 +1169,9 @@ litecoin.node=ltcd ; testing with embedded etcd. ; db.etcd.embedded_log_file=/path/etcd.log +; The maximum message size in bytes that we may send to etcd. Defaults to 32 MiB. +; db.etcd.max_msg_size=33554432 + [postgres] ; Postgres connection string. ; db.postgres.dsn=postgres://lnd:lnd@localhost:45432/lnd?sslmode=disable