Skip to content

Commit 136406f

Browse files
karalabepull[bot]
authored andcommitted
trie/triedb/pathdb: make shutdown journal log friendlier (#27905)
1 parent e341e01 commit 136406f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

trie/triedb/pathdb/journal.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"errors"
2222
"fmt"
2323
"io"
24+
"time"
2425

2526
"github.com/ethereum/go-ethereum/common"
2627
"github.com/ethereum/go-ethereum/core/rawdb"
@@ -341,6 +342,14 @@ func (db *Database) Journal(root common.Hash) error {
341342
if l == nil {
342343
return fmt.Errorf("triedb layer [%#x] missing", root)
343344
}
345+
disk := db.tree.bottom()
346+
if l, ok := l.(*diffLayer); ok {
347+
log.Info("Persisting dirty state to disk", "head", l.block, "root", root, "layers", l.id-disk.id+disk.buffer.layers)
348+
} else { // disk layer only on noop runs (likely) or deep reorgs (unlikely)
349+
log.Info("Persisting dirty state to disk", "root", root, "layers", disk.buffer.layers)
350+
}
351+
start := time.Now()
352+
344353
// Run the journaling
345354
db.lock.Lock()
346355
defer db.lock.Unlock()
@@ -373,6 +382,6 @@ func (db *Database) Journal(root common.Hash) error {
373382

374383
// Set the db in read only mode to reject all following mutations
375384
db.readOnly = true
376-
log.Info("Stored journal in triedb", "disk", diskroot, "size", common.StorageSize(journal.Len()))
385+
log.Info("Persisted dirty state to disk", "size", common.StorageSize(journal.Len()), "elapsed", common.PrettyDuration(time.Since(start)))
377386
return nil
378387
}

0 commit comments

Comments
 (0)