Skip to content

Commit

Permalink
sharedcache: tolerate small sizes
Browse files Browse the repository at this point in the history
Instead of erroring out when the cache size is too small given the
number of shards, we up the size as needed.

Fixes #2935.
  • Loading branch information
RaduBerinde committed Sep 26, 2023
1 parent 895ffed commit 6604500
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions objstorage/objstorageprovider/sharedcache/shared_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ func Open(
sizeBytes int64,
numShards int,
) (*Cache, error) {
min := shardingBlockSize * int64(numShards)
if sizeBytes < min {
return nil, errors.Errorf("cache size %d lower than min %d", sizeBytes, min)
if minSize := shardingBlockSize * int64(numShards); sizeBytes < minSize {
// Up the size so that we have one block per shard. In practice, this should
// only happen in tests.
sizeBytes = minSize
}

c := &Cache{
Expand Down

0 comments on commit 6604500

Please sign in to comment.