Running out of memory on a 2GB box - Initializing chainstate Chainstate [ibd] @ height -1 (null) #31573

issue otech47 openend this issue on December 27, 2024
  1. otech47 commented at 3:55 pm on December 27, 2024: none

    I have a server running a pruned bitcoind node as a Docker container with 2G RAM. There are some other services using maybe 500MB of the RAM but I got into a state where bitcoind tries to initialize the chainstate but then starts sucking up all the available RAM so it gets killed with OOM error. Docker then restarts it and it loops like this forever

    I tried to configure bitcoind to be constrained to low memory but it doesn’t seem to have any effect

     0[main]
     1printtoconsole=1
     2rpcallowip=::/0
     3rpcallowip=0.0.0.0/0
     4prune=550
     5txindex=0
     6rpcport=8332
     7rpcbind=0.0.0.0:8332
     8dbcache=20
     9maxmempool=5
    10maxconnections=32
    11
    12assumevalid=00000000000000000002923a7456aa3d4adce139cd16550c3ff36d07cc45d251
    

    This node did successfully complete IBD at one point and it is unknown exactly why or when it got into this OOM loop. Maybe it has something to do with the assumevalid? In fact the way this docker container was constructed is that on every restart it would get the latest block hash from an esplora server and set that hash to assumevalid in bitcoin.conf before initializing. So I am theorizing that maybe this unusual behavior created some sort of data that needs to be fully loaded into memory before proceeding and so it gets killed.

    Below are the logs of a typical startup of bitcoind at this point. I have tried locking the hash of assumevalid and disabled the esplora auto-update logic but it didn’t have any effect.

    As a last resort I will clear out the chainstate and try to do IBD again but am trying to surgically fix it if possible. Decided to open an issue here in case there is some edge case optimization to prevent bitcoind from having to eat up 1.5GB of memory.

    Any suggestions are appreciated and feel free to close if there is nothing actionable and this all just came down to a misuse of assumevalid. Thanks!

     0bitcoind-1  | 2024-12-27T15:00:16Z Bitcoin Core version v26.0.0 (release build)
     1bitcoind-1  | 2024-12-27T15:00:16Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
     2bitcoind-1  | 2024-12-27T15:00:16Z Using RdSeed as an additional entropy source
     3bitcoind-1  | 2024-12-27T15:00:16Z Using RdRand as an additional entropy source
     4bitcoind-1  | 2024-12-27T15:00:16Z Default data directory /home/bitcoin/.bitcoin
     5bitcoind-1  | 2024-12-27T15:00:16Z Using data directory /home/bitcoin/.bitcoin
     6bitcoind-1  | 2024-12-27T15:00:16Z Config file: /home/bitcoin/.bitcoin/bitcoin.conf
     7bitcoind-1  | 2024-12-27T15:00:16Z Config file arg: [main] assumevalid="00000000000000000002923a7456aa3d4adce139cd16550c3ff36d07cc45d251"
     8bitcoind-1  | 2024-12-27T15:00:16Z Config file arg: [main] dbcache="20"
     9bitcoind-1  | 2024-12-27T15:00:16Z Config file arg: [main] maxconnections="32"
    10bitcoind-1  | 2024-12-27T15:00:16Z Config file arg: [main] maxmempool="5"
    11bitcoind-1  | 2024-12-27T15:00:16Z Config file arg: [main] printtoconsole="1"
    12bitcoind-1  | 2024-12-27T15:00:16Z Config file arg: [main] prune="550"
    13bitcoind-1  | 2024-12-27T15:00:16Z Config file arg: [main] rpcallowip="::/0"
    14bitcoind-1  | 2024-12-27T15:00:16Z Config file arg: [main] rpcallowip="0.0.0.0/0"
    15bitcoind-1  | 2024-12-27T15:00:16Z Config file arg: [main] rpcauth=****
    16bitcoind-1  | 2024-12-27T15:00:16Z Config file arg: [main] rpcbind="0.0.0.0:8332"
    17bitcoind-1  | 2024-12-27T15:00:16Z Config file arg: [main] rpcport="8332"
    18bitcoind-1  | 2024-12-27T15:00:16Z Config file arg: [main] txindex="0"
    19bitcoind-1  | 2024-12-27T15:00:16Z Using at most 32 automatic connections (1048576 file descriptors available)
    20bitcoind-1  | 2024-12-27T15:00:16Z Using 16 MiB out of 16 MiB requested for signature cache, able to store 524288 elements
    21bitcoind-1  | 2024-12-27T15:00:16Z Using 16 MiB out of 16 MiB requested for script execution cache, able to store 524288 elements
    22bitcoind-1  | 2024-12-27T15:00:16Z Script verification uses 0 additional threads
    23bitcoind-1  | 2024-12-27T15:00:16Z Binding RPC on address 0.0.0.0 port 8332
    24bitcoind-1  | 2024-12-27T15:00:16Z WARNING: the RPC server is not safe to expose to untrusted networks such as the public internet
    25bitcoind-1  | 2024-12-27T15:00:16Z [http] creating work queue of depth 16
    26bitcoind-1  | 2024-12-27T15:00:16Z Using random cookie authentication.
    27bitcoind-1  | 2024-12-27T15:00:16Z scheduler thread start
    28bitcoind-1  | 2024-12-27T15:00:16Z Generated RPC authentication cookie /home/bitcoin/.bitcoin/.cookie
    29bitcoind-1  | 2024-12-27T15:00:16Z Using rpcauth authentication.
    30bitcoind-1  | 2024-12-27T15:00:16Z [http] starting 4 worker threads
    31bitcoind-1  | 2024-12-27T15:00:16Z Using wallet directory /home/bitcoin/.bitcoin
    32bitcoind-1  | 2024-12-27T15:00:16Z init message: Verifying wallet(s)…
    33bitcoind-1  | 2024-12-27T15:00:16Z Using /16 prefix for IP bucketing
    34bitcoind-1  | 2024-12-27T15:00:16Z init message: Loading P2P addresses…
    35bitcoind-1  | 2024-12-27T15:00:17Z Loaded 64073 addresses from peers.dat  284ms
    36bitcoind-1  | 2024-12-27T15:00:17Z init message: Loading banlist…
    37bitcoind-1  | 2024-12-27T15:00:17Z SetNetworkActive: true
    38bitcoind-1  | 2024-12-27T15:00:17Z Cache configuration:
    39bitcoind-1  | 2024-12-27T15:00:17Z * Using 2.0 MiB for block index database
    40bitcoind-1  | 2024-12-27T15:00:17Z * Using 8.0 MiB for chain state database
    41bitcoind-1  | 2024-12-27T15:00:17Z * Using 10.0 MiB for in-memory UTXO set (plus up to 4.8 MiB of unused mempool space)
    42bitcoind-1  | 2024-12-27T15:00:17Z init message: Loading block index…
    43bitcoind-1  | 2024-12-27T15:00:17Z Assuming ancestors of block 00000000000000000002923a7456aa3d4adce139cd16550c3ff36d07cc45d251 have valid signatures.
    44bitcoind-1  | 2024-12-27T15:00:17Z Setting nMinimumChainWork=000000000000000000000000000000000000000052b2559353df4117b7348b64
    45bitcoind-1  | 2024-12-27T15:00:17Z Prune configured to target 550 MiB on disk for block and undo files.
    46bitcoind-1  | 2024-12-27T15:00:17Z Opening LevelDB in /home/bitcoin/.bitcoin/blocks/index
    47bitcoind-1  | 2024-12-27T15:00:17Z Opened LevelDB successfully
    48bitcoind-1  | 2024-12-27T15:00:17Z Using obfuscation key for /home/bitcoin/.bitcoin/blocks/index: 0000000000000000
    49bitcoind-1  | 2024-12-27T15:00:22Z LoadBlockIndexDB: last block file = 4657
    50bitcoind-1  | 2024-12-27T15:00:22Z LoadBlockIndexDB: last block file info: CBlockFileInfo(blocks=25, size=39362654, heights=874318...874342, time=2024-12-11...2024-12-12)
    51bitcoind-1  | 2024-12-27T15:00:22Z Checking all blk files are present...
    52bitcoind-1  | 2024-12-27T15:00:22Z LoadBlockIndexDB(): Block files have previously been pruned
    53bitcoind-1  | 2024-12-27T15:00:23Z Initializing chainstate Chainstate [ibd] @ height -1 (null)
    54bitcoind-1  | 2024-12-27T15:00:23Z Opening LevelDB in /home/bitcoin/.bitcoin/chainstate
    
  2. SecondPort referenced this in commit 018b7fa807 on Dec 27, 2024
  3. SecondPort referenced this in commit 60369ab83f on Dec 27, 2024
  4. maflcko added the label UTXO Db and Indexes on Jan 2, 2025
  5. maflcko added the label Resource usage on Jan 2, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-01-21 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me