making NumSnapshotsToKeep configurable
This commit is contained in:
parent
4ebf3f1d44
commit
fa5de8e09a
|
@ -633,14 +633,19 @@ func (s *Scorch) removeOldBoltSnapshots() (numRemoved int, err error) {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(persistedEpochs) <= NumSnapshotsToKeep {
|
numSnapshotsToKeep := NumSnapshotsToKeep
|
||||||
|
if val, ok := s.config["numSnapshotsToKeep"].(float64); ok && val > 0 {
|
||||||
|
numSnapshotsToKeep = int(val)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(persistedEpochs) <= numSnapshotsToKeep {
|
||||||
// we need to keep everything
|
// we need to keep everything
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// make a map of epochs to protect from deletion
|
// make a map of epochs to protect from deletion
|
||||||
protectedEpochs := make(map[uint64]struct{}, NumSnapshotsToKeep)
|
protectedEpochs := make(map[uint64]struct{}, numSnapshotsToKeep)
|
||||||
for _, epoch := range persistedEpochs[0:NumSnapshotsToKeep] {
|
for _, epoch := range persistedEpochs[0:numSnapshotsToKeep] {
|
||||||
protectedEpochs[epoch] = struct{}{}
|
protectedEpochs[epoch] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue