Skip to content

Commit c91efdc

Browse files
yperbasismh0lt
andauthored
Only reduce the consensus db size based on flags values (erigontech#8321) (erigontech#8327)
This is to fix an issue with resource usage if the db.size.limit is increased from its default setting of 2TB. This is applied to the chain DB, but should not be used on the consensus DB which has smaller data requirements. Expanding both DBs results in excessive RAM being reserved by the underlying OS. --------- Co-authored-by: Mark Holt <[email protected]>
1 parent b8744d9 commit c91efdc

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

erigon-lib/kv/mdbx/kv_mdbx.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ type MdbxOpts struct {
7070
inMem bool
7171
}
7272

73+
const DefaultMapSize = 2 * datasize.TB
74+
const DefaultGrowthStep = 2 * datasize.GB
75+
7376
func NewMDBX(log log.Logger) MdbxOpts {
7477
opts := MdbxOpts{
7578
bucketsCfg: WithChaindataTables,
@@ -81,8 +84,8 @@ func NewMDBX(log log.Logger) MdbxOpts {
8184
// but for reproducibility of benchmarks - please don't rely on Available RAM
8285
dirtySpace: 2 * (memory.TotalMemory() / 42),
8386

84-
mapSize: 2 * datasize.TB,
85-
growthStep: 2 * datasize.GB,
87+
mapSize: DefaultMapSize,
88+
growthStep: DefaultGrowthStep,
8689
mergeThreshold: 3 * 8192,
8790
shrinkThreshold: -1, // default
8891
label: kv.InMem,

node/node.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ func OpenDatabase(config *nodecfg.Config, label kv.Label, name string, readonly
325325
}
326326

327327
switch label {
328-
case kv.ChainDB, kv.ConsensusDB:
328+
case kv.ChainDB:
329329
if config.MdbxPageSize.Bytes() > 0 {
330330
opts = opts.PageSize(config.MdbxPageSize.Bytes())
331331
}
@@ -335,6 +335,18 @@ func OpenDatabase(config *nodecfg.Config, label kv.Label, name string, readonly
335335
if config.MdbxGrowthStep > 0 {
336336
opts = opts.GrowthStep(config.MdbxGrowthStep)
337337
}
338+
case kv.ConsensusDB:
339+
if config.MdbxPageSize.Bytes() > 0 {
340+
opts = opts.PageSize(config.MdbxPageSize.Bytes())
341+
}
342+
// Don't adjust up the consensus DB - this will lead to resource exhaustion lor large map sizes
343+
if config.MdbxDBSizeLimit > 0 && config.MdbxDBSizeLimit < mdbx.DefaultMapSize {
344+
opts = opts.MapSize(config.MdbxDBSizeLimit)
345+
}
346+
// Don't adjust up the consensus DB - to align with db size limit above
347+
if config.MdbxGrowthStep > 0 && config.MdbxGrowthStep < mdbx.DefaultGrowthStep {
348+
opts = opts.GrowthStep(config.MdbxGrowthStep)
349+
}
338350
default:
339351
opts = opts.GrowthStep(16 * datasize.MB)
340352
}

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var (
3333
const (
3434
VersionMajor = 2 // Major version component of the current release
3535
VersionMinor = 50 // Minor version component of the current release
36-
VersionMicro = 0 // Patch version component of the current release
36+
VersionMicro = 1 // Patch version component of the current release
3737
VersionModifier = "" // Modifier component of the current release
3838
VersionKeyCreated = "ErigonVersionCreated"
3939
VersionKeyFinished = "ErigonVersionFinished"

0 commit comments

Comments
 (0)