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

Geth Fatal: Could not open database #1996

Closed swlfigo closed 11 months ago

swlfigo commented 11 months ago

Using Geth v1.3.1 Following Official Documentation: https://docs.bnbchain.org/docs/validator/fullnode/

I download Geth fast node Snapshot from 48Club: https://github.com/48Club/bsc-snapshots#geth-fast-node

First I create datadir using this command: geth --datadir ./node --db.engine=pebble init ./genesis.json

then I replace donwloaded snapshot chaindata to replace folder in node's same place ./node/geth/chaindata

then I run Geth with this command: geth --config ./config.toml --datadir ./node --cache 8000 --rpc.allow-unprotected-txs --txlookuplimit=0 --syncmode=full --tries-verify-mode=none --pruneancient=true --history.transactions=0 --db.engine=pebble

It shows error:

database=/node/geth/chaindata cache=3.12GiB 
databaseVersion: 8 (0x8)
headBlockHash: 0x753f3b10dc5400e0dd27e9470e5148ff557d3101a46a82724586838971fc1fcd
headFastBlockHash: x753f3b10dc5400e0dd27e9470e5148ff557d3101a46a82724586838971fc1fco
headHeaderHash: 0x753f3b10dc5400e0dd27e9470e5148ff557d3101a46a82724586838971fc1fcd
lastPivotNumber: <nil>
len(snapshotSyncStatus): o bytes
snapshotDisabled: false
snapshotJournal: 6355917 bytes
snapshotRecoveryNumber: <nil>
snapshotRoot: 0x660887bd6cddadb76041e13a5d21933a18c494104993ed2a1666de3cf63b2836
txIndexTail:  (x0)
fastTxLookupLimit: <nil>
Fatal: Could not open database: open /node/geth/chaindata/ancient/chain/bodies.cidx: no such file or directorv

I have tried backup files in ancient/chain after first initial with genesis.json, which it included database needed files, after move 48club snapshot chaindata to datadir, I replace original ancient/chain data in it. And Geth finally run and sync successfully

After successfully run geth , the file in node/geth/chaindata/ancient will lost and can't run next time

Is any wrong step I maked?

RenRick commented 11 months ago

”After successfully run geth , the file in node/geth/chaindata/ancient will lost and can't run next time“ Could you pls share the log? Or is it the same error with that you attached above? thanks

joeylichang commented 11 months ago

Step3:delete --pruneancient=true flag try again. geth --config ./config.toml --datadir ./node --cache 8000 --rpc.allow-unprotected-txs --txlookuplimit=0 --syncmode=full --tries-verify-mode=none --history.transactions=0 --db.engine=pebble

note: don't replace snapshot's ancient/chain data.

swlfigo commented 11 months ago

Step3:delete --pruneancient=true flag try again. geth --config ./config.toml --datadir ./node --cache 8000 --rpc.allow-unprotected-txs --txlookuplimit=0 --syncmode=full --tries-verify-mode=none --history.transactions=0 --db.engine=pebble

note: don't replace snapshot's ancient/chain data.

@joeylichang The snapshot downloaded from 48club, there is no xxxxx.cidx files in snapshot/geth/chaindata/ancient/ folder, if I don't replace folder created with genesis.json , Geth will show can't open DB which can't find these files.

After Delete --pruneancient=true flag , same error . the main reason is missing xxxx files which open db needed

swlfigo commented 11 months ago

”After successfully run geth , the file in node/geth/chaindata/ancient will lost and can't run next time“ Could you pls share the log? Or is it the same error with that you attached above? thanks

@RenRick same error, After First Success run, all file (eg. xxxx.cidx ) all missed in ancient folder.

weiihann commented 11 months ago

This should be due to the pruneancient bug, which has been fixed in this PR https://github.com/bnb-chain/bsc/pull/1986.

flywukong commented 11 months ago

Compile geth with v1.3.1 + this PR https://github.com/bnb-chain/bsc/pull/1986, and try run with the same snapshot and the commands as the issue descriped, it sync successfully .

t=2023-11-22T06:13:17+0000 lvl=info msg="Block synchronisation started"
t=2023-11-22T06:13:23+0000 lvl=info msg="Importing sidechain segment"           start=33,660,920 end=33,661,091
t=2023-11-22T06:13:24+0000 lvl=warn msg="Inserted known block"                  number=33,660,923 hash=0xec091fe0ebdfa5d2551bf5ad34a30be0e7e75ce48f7eb34beedd7b02b4e116a5 uncles=0 txs=0 gas=0 root=0x18daf402293b4b25a0f1f7f167c49e891e5f42479607d54a0989085528f560e9
t=2023-11-22T06:091fe0ebdfa5d2551bf5ad34a30be0e7e75ce48f7eb34beedd7b02b4e116a5 oldblocks=166 newnum=33,660,923 newhash=0xec091fe0ebdfa5d2551bf5ad34a30be0e7e75ce48f7eb34beedd7b02b4e116a5 newblocks=0
t=2023-11-22T06:13:31+0000 lvl=info msg="Imported new chain segment"             number=33,660,934 hash=0x62a0dd69a3943b60727605c76fbf1d5cea8e3ce2c0a57821f087cfbfda237ff1 miner=0xCc8E6d00C17eB431350C6c50d8b8F05176b90b11 blocks=15 txs=2313 mgas=286.555 elapsed=8.412s mgasps=34.065 age=1d15h6m  triedirty="0.00 B"13:25+0000 lvl=eror msg="Impossible reorg, please file an issue" oldnum=33,660,923 oldhash=0xec091fe0ebdfa5d2551bf5ad34a30be0e7e75ce48f7eb34beedd7b02b4e116a5 oldblocks=166 newnum=33,660,923 newhash=0xec091fe0ebdfa5d2551bf5ad34a30be0e7e75ce48f7eb34beedd7b02b4e116a5 newblocks=0
t=2023-11-22T06:13:31+0000 lvl=info msg="Imported new chain segment"             number=33,660,934 hash=0x62a0dd69a3943b60727605c76fbf1d5cea8e3ce2c0a57821f087cfbfda237ff1 miner=0xCc8E6d00C17eB431350C6c50d8b8F05176b90b11 blocks=15 txs=2313 mgas=286.555 elapsed=8.412s mgasps=34.065 age=1d15h6m  triedirty="0.00 B"

Pls notice it is not needed to replace original ancient/chain data after fixed now.

swlfigo commented 11 months ago

This should be due to the pruneancient bug, which has been fixed in this PR #1986.

problem is fixed with this PR, Thx!

swlfigo commented 11 months ago

problem is fixed with this PR, Thx!

problem is fixed with this PR, Thx!