diff --git a/db/state/deduplicate.go b/db/state/deduplicate.go index 8ac73cae6b7..6ae0bfffeff 100644 --- a/db/state/deduplicate.go +++ b/db/state/deduplicate.go @@ -41,6 +41,10 @@ func (ht *HistoryRoTx) deduplicateFiles(ctx context.Context, indexFiles, history return nil } + if len(indexFiles) > 1 || len(historyFiles) > 1 { + return fmt.Errorf("wrong deduplication interval from %d to %d", r.history.from, r.history.to) + } + var decomp *seg.Decompressor fromStep, toStep := kv.Step(r.history.from/ht.stepSize), kv.Step(r.history.to/ht.stepSize) diff --git a/db/state/history.go b/db/state/history.go index c2da09fc64f..823f501c113 100644 --- a/db/state/history.go +++ b/db/state/history.go @@ -1459,7 +1459,18 @@ func (ht *HistoryRoTx) CompactRange(ctx context.Context, fromTxNum, toTxNum uint return err } - return ht.deduplicateFiles(ctx, efFiles, vFiles, mergeRange, background.NewProgressSet()) + for i := 0; i < len(efFiles); i++ { + mergeRange = NewHistoryRanges( + *NewMergeRange("", true, vFiles[i].startTxNum, vFiles[i].endTxNum), + *NewMergeRange("", true, efFiles[i].startTxNum, efFiles[i].endTxNum), + ) + + if err := ht.deduplicateFiles(ctx, []*FilesItem{efFiles[i]}, []*FilesItem{vFiles[i]}, mergeRange, background.NewProgressSet()); err != nil { + return err + } + } + + return nil } func (ht *HistoryRoTx) idxRangeOnDB(key []byte, startTxNum, endTxNum int, asc order.By, limit int, roTx kv.Tx) (stream.U64, error) {