tns: checkpoint wal periodically while backfilling (#3516)

Witout this, we end up with a massive .wal file that needs to be
checkpointed on first startup (which takes a few minutes) - it's much
more efficient to do smaller checkpoints, it turns out.
This commit is contained in:
Jacek Sieka 2022-03-18 12:32:20 +01:00 committed by GitHub
parent 8395f7de8c
commit b3d80827fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -1836,6 +1836,7 @@ proc rebuildIndex*(dag: ChainDAGRef) =
withState(state[]): withState(state[]):
dag.db.putState(state) dag.db.putState(state)
dag.db.checkpoint()
state_root = state.root state_root = state.root

View File

@ -73,6 +73,8 @@ proc doTrustedNodeSync*(
let let
db = BeaconChainDB.new(databaseDir, inMemory = false) db = BeaconChainDB.new(databaseDir, inMemory = false)
defer:
db.close()
var var
dbCache = DbCache(summaries: db.loadSummaries()) dbCache = DbCache(summaries: db.loadSummaries())
@ -391,6 +393,9 @@ proc doTrustedNodeSync*(
continue continue
gets[int(i mod gets.lenu64)] = downloadBlock(slot) gets[int(i mod gets.lenu64)] = downloadBlock(slot)
if i mod 1024 == 0:
db.checkpoint() # Transfer stuff from wal periodically
true true
else: else:
notice "Database initialized, historical blocks will be backfilled when starting the node", notice "Database initialized, historical blocks will be backfilled when starting the node",