From 4b9199ba2a1a1bc82339909c07de7e30a6861ba4 Mon Sep 17 00:00:00 2001 From: Giulio rebuffo Date: Sun, 29 Sep 2024 22:04:25 +0200 Subject: [PATCH] Fixed panic of `.idx` during merge of historical `.idxes` (#12133) --- eth/stagedsync/stage_snapshots.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/eth/stagedsync/stage_snapshots.go b/eth/stagedsync/stage_snapshots.go index 958e58c5041..df7a01f801e 100644 --- a/eth/stagedsync/stage_snapshots.go +++ b/eth/stagedsync/stage_snapshots.go @@ -74,7 +74,14 @@ import ( "github.com/erigontech/erigon/turbo/snapshotsync/freezeblocks" ) -const pruneMarkerSafeThreshold = 1000 // Keep 1000 blocks of markers in the DB below snapshot available blocks +const ( + /* + we strive to read indexes from snapshots instead to db... this means that there can be sometimes (e.g when we merged past indexes), + a situation when we need to read indexes and we choose to read them from either a corrupt index or an incomplete index. + so we need to extend the threshold to > max_merge_segment_size. + */ + pruneMarkerSafeThreshold = snaptype.Erigon2MergeLimit * 1.5 // 1.5x the merge limit +) type SnapshotsCfg struct { db kv.RwDB