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[]):
dag.db.putState(state)
dag.db.checkpoint()
state_root = state.root

View File

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