bnb-chain / bsc

A BNB Smart Chain client based on the go-ethereum fork
GNU Lesser General Public License v3.0
2.73k stars 1.56k forks source link

Migrating from leveldb to pebbledb. How to enable pebble db backend? #2647

Closed qezz closed 2 months ago

qezz commented 2 months ago

We were running v1.4.10 on hash+leveldb.

Following the https://forum.bnbchain.org/t/faq-pbss-pebbledb/2260

As it is already the default mode, you don’t need extra configuration to use PBSS + PebbleDB.

I fetched the snapshot from https://github.com/48Club/bsc-snapshots?tab=readme-ov-file#geth-full-node-with-pbss, replaced the previous data dir with this one.

I didnt change any args, as it says in the https://forum.bnbchain.org/t/faq-pbss-pebbledb/2260

After I started the node, I see

Aug 14 09:47:52 geth[88073]: INFO [08-14|09:47:52.454] Using leveldb as the backing database
Aug 14 09:47:52 geth[88117]: INFO [08-14|09:47:52.918] Using leveldb as the backing database
Aug 14 09:47:57 geth[88117]: INFO [08-14|09:47:57.314] Using LevelDB as the backing database
Aug 14 09:47:57 geth[88117]: INFO [08-14|09:47:57.360] State scheme set to default              scheme=path
Aug 14 09:47:57 geth[88117]: INFO [08-14|09:47:57.360] Allocated memory caches                  state_scheme=path trie_clean_cache=33.32GiB trie_dirty_cache=256.00MiB snapshot_cache=16.78GiB

Moreover the database dir (chaindata) was automatically wiped by the process, and it's now trying to fetch data from 4y ago.

What am I doing wrong?

zzzckck commented 2 months ago

@qezz could you provide the arguments of how to run your node? And I will double check with 48Club, seems like they provide the snapshot with Path & LevelDB mode.

qezz commented 2 months ago

@zzzckck here are the args we use

ExecStart=/opt/validators/bsc/bin/1.4.10/geth \
         --datadir /opt/validators/bsc/data \
         --config /opt/validators/bsc/config/config.toml \
         --monitor.doublesign \
         --history.transactions=0 \
         --syncmode=full --tries-verify-mode=none --pruneancient=true --diffblock=5000 \
         --cache 98304 --metrics --metrics.addr="0.0.0.0"
qezz commented 2 months ago

To clarify, before restart with the new datadir I switched the binary to the "latest stable release", which is 1.4.13

buddh0 commented 2 months ago

@qezz

  1. how does your datadir looks like? /opt/validators/bsc/data/chaindata or /opt/validators/bsc/data/geth/chaindata? the later is right.
  2. maybe you configured DBEngine = leveldb in config.toml, if so please remove it
qezz commented 2 months ago

@buddh0

1

root@rpc05:/opt/validators/bsc# realpath data/geth/chaindata/
/opt/validators/bsc/data/geth/chaindata

root@rpc05:/opt/validators/bsc# ls -lah data/geth/chaindata/LOG
-rw-r--r-- 1 bsc bsc 533K Aug 19 19:37 data/geth/chaindata/LOG

2

root@rpc05:/opt/validators/bsc# cat config/config.toml | grep -Ei DBEngine | wc -l
0
buddh0 commented 2 months ago

I tried many times locally, not find the same issue I think your action replaced the previous data dir with this one maybe not execute correctly may you do more check?

  1. before restart with new data, are there. any '.ldb' files in data/geth/chaindata/? or '.sst' exist? '.ldb' indacate the leveldb, and '.sst' files indacate the pebble db.
  2. check the size before restart du -sh /opt/validators/bsc/data/geth
NathanBSC commented 2 months ago

if no other people report the same issue, this issue will be closed 3 days later (08/23)

qezz commented 2 months ago

I'm OOO for 2 days, will check back a bit later.

qezz commented 2 months ago

By any chance, is there a flag to force the db backend to be the pebbledb? So we don't need to guess if it's applied properly or not

zzzckck commented 2 months ago

By any chance, is there a flag to force the db backend to be the pebbledb? So we don't need to guess if it's applied properly or not

I am afraid there is no such flag, the database will be determined since genesis block and can not be changed after that.

qezz commented 2 months ago

@zzzckck just to clarify then, what is this option?

image
zzzckck commented 2 months ago

@zzzckck just to clarify then, what is this option? image

this option try to use PebbleDB, and it will report error if the underlying database format is LevelDB. It can not covert the database, but indicate user wanna use PebbleDB, but it is not the case, it will fail.

qezz commented 2 months ago

this option try to use PebbleDB, and it will report error if the underlying database format is LevelDB.

That's exactly what I need, thanks.

qezz commented 2 months ago

It seems to help or whatever. Differences are:

UPD:

root@rpc05:~# journalctl -alxfu bsc -n 100000 --no-host | grep -iE "scheme|backing database"
Aug 28 11:22:35 geth[2045963]: INFO [08-28|11:22:35.088] Using pebble as the backing database
Aug 28 11:22:54 geth[2045963]: INFO [08-28|11:22:54.651] State scheme set to already existing disk db scheme=path
Aug 28 11:22:54 geth[2045963]: INFO [08-28|11:22:54.651] Allocated memory caches                  state_scheme=path trie_clean_cache=33.32GiB trie_dirty_cache=256.00MiB snapshot_cache=16.78GiB