-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Background
I run LND with PostgreSQL backend on a virtual server on server hardware. There is 4 GB RAM dedicated to LND and PostgreSQL only (bitcoind runs on another virtual server). I have about 8 channels opened and there is not much routing nor load at all.
Since update to 18.5-beta day before yesterday (not sure if it is related), LND crashed twice with this error:
[CRT] SQLB: Caught unhandled error: ERROR: out of shared memory (SQLSTATE 53200)
[INF] SQLB: Sending request for shutdown
[ERR] DISC: Unable to determine if node **** is advertised: unknown postgres error: ERROR: out of shared memory (SQLSTATE 53200)
This "out of memory" error is strange as there should be enough memory available (there is only 25 % of 4 GB memory used in average). Postgres memory configuration follows:
shared_buffers = 512MB
max_connections = 64 # RTL does not work well if set to lower value
work_mem = 8MB
maintenance_work_mem = 64MB # should not be relevant for this issue
effective_cache_size = 2GB # only an estimation for query planner
The whole database size is currently 270 MB.
There could be some issue with the db locks, as I found these errors in the postgres log:
ERROR: out of shared memory
HINT: You might need to increase "max_pred_locks_per_transaction".
STATEMENT: SELECT id FROM channeldb_kv WHERE parent_id IS NULL AND key=$1 AND value IS NULL
I also found another error in postgres log and I am not sure if it is related:
ERROR: could not serialize access due to read/write dependencies among transactions
DETAIL: Reason code: Canceled on identification as a pivot, during write.
HINT: The transaction might succeed if retried.
STATEMENT: INSERT INTO channeldb_kv (key, value, parent_id) VALUES($1, $2, $3) ON CONFLICT (key, parent_id) WHERE parent_id IS NOT NULL DO UPDATE SET value=$2 WHERE channeldb_kv.value IS NOT NULL
Similar errors were mentioned in #8049 and it should be fixed already, so I am confused.
Your environment
lnd Version: 0.18.5-betaLinux 6.1.0-31-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.128-1 (2025-02-07) x86_64 GNU/LinuxBitcoin Core version v28.1.0- Dedicated virtual server for LND and PostgreSQL with 4 GB RAM and 4 vCPU. Server hardware (Xeon CPU, ECC RAM, SSD drives with RAID, ...)
Steps to reproduce
I will provide more details if I would be able to discover some steps to reproduce.
Expected behaviour
LND with postgres does not consume nor demand so much RAM with such low load.
Actual behaviour
Postgres returns "out of shared memory" and LND crashes.