Skip to content

Commit fd7d35b

Browse files
protolambdasebastianst
authored andcommitted
pathdb: Pathdb full write-buffer check (#497)
* pathdb: limit diff layers in write-buffer * fork.yaml: document pathdb fix
1 parent c5afb51 commit fd7d35b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

fork.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ def:
205205
globs:
206206
- "eth/downloader/downloader.go"
207207
- "eth/downloader/receiptreference.go"
208+
- title: PathDB diff-layers limit
209+
description: |
210+
Prevent the write-buffer to grow too large, to keep the journal optional,
211+
and not restart on top of unavailable state.
212+
globs:
213+
- "triedb/pathdb/buffer.go"
208214
- title: Discv5 node discovery
209215
description: Fix discv5 option to allow discv5 to be an active source for node-discovery.
210216
globs:

triedb/pathdb/buffer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ func (b *buffer) empty() bool {
114114
// full returns an indicator if the size of accumulated content exceeds the
115115
// configured threshold.
116116
func (b *buffer) full() bool {
117-
return b.size() > b.limit
117+
// Limit not just by data size, but also the number of layers:
118+
// if we allow the write-buffer to become larger,
119+
// the journal becomes critical to not roll back to an unavailable state.
120+
return b.size() > b.limit || b.layers >= uint64(maxDiffLayers)
118121
}
119122

120123
// size returns the approximate memory size of the held content.

0 commit comments

Comments
 (0)