Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions pkg/storer/cachestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ func (db *DB) cacheWorker(ctx context.Context) {
continue
}

evict := uint64(size - capc)
if evict < db.reserveOptions.cacheMinEvictCount { // evict at least a min count
evict = db.reserveOptions.cacheMinEvictCount
}
evict := max(uint64(size-capc),
// evict at least a min count
db.reserveOptions.cacheMinEvictCount)

dur := captureDuration(time.Now())
err := db.cacheObj.RemoveOldest(ctx, db.storage, evict)
Expand Down
5 changes: 1 addition & 4 deletions pkg/storer/migration/refCntSize.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ func RefCountSizeInc(s storage.BatchStore, logger log.Logger) func() error {
}

for i := 0; i < len(itemsToDelete); i += 10000 {
end := i + 10000
if end > len(itemsToDelete) {
end = len(itemsToDelete)
}
end := min(i+10000, len(itemsToDelete))

b := s.Batch(context.Background())
for _, item := range itemsToDelete[i:end] {
Expand Down
5 changes: 1 addition & 4 deletions pkg/storer/migration/reserveRepair.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ func ReserveRepairer(
batchSize := 1000

for i := 0; i < len(chunkBinItems); i += batchSize {
end := i + batchSize
if end > len(chunkBinItems) {
end = len(chunkBinItems)
}
end := min(i+batchSize, len(chunkBinItems))
err := st.Run(context.Background(), func(s transaction.Store) error {
for _, item := range chunkBinItems[i:end] {
err := s.IndexStore().Delete(item)
Expand Down
7 changes: 3 additions & 4 deletions pkg/storer/reserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,9 @@ func (db *DB) unreserve(ctx context.Context) (err error) {
default:
}

evict := target - totalEvicted
if evict < int(db.reserveOptions.minEvictCount) { // evict at least a min count
evict = int(db.reserveOptions.minEvictCount)
}
evict := max(target-totalEvicted,
// evict at least a min count
int(db.reserveOptions.minEvictCount))

binEvicted, err := db.evictBatch(ctx, b, evict, radius)
// eviction happens in batches, so we need to keep track of the total
Expand Down
Loading