diff --git a/storage/remote/queue_manager.go b/storage/remote/queue_manager.go index d7981a0936..32a4aba4ae 100644 --- a/storage/remote/queue_manager.go +++ b/storage/remote/queue_manager.go @@ -859,11 +859,13 @@ func (t *QueueManager) calculateDesiredShards() int { ) level.Debug(t.logger).Log("msg", "QueueManager.updateShardsLoop", "lowerBound", lowerBound, "desiredShards", desiredShards, "upperBound", upperBound) + + desiredShards = math.Ceil(desiredShards) // Round up to be on the safe side. if lowerBound <= desiredShards && desiredShards <= upperBound { return t.numShards } - numShards := int(math.Ceil(desiredShards)) + numShards := int(desiredShards) // Do not downshard if we are more than ten seconds back. if numShards < t.numShards && delay > 10.0 { level.Debug(t.logger).Log("msg", "Not downsharding due to being too far behind") diff --git a/storage/remote/queue_manager_test.go b/storage/remote/queue_manager_test.go index 56498a0f08..a2d63b0bcb 100644 --- a/storage/remote/queue_manager_test.go +++ b/storage/remote/queue_manager_test.go @@ -1025,7 +1025,7 @@ func TestCalculateDesiredShardsDetail(t *testing.T) { dataIn: 10, dataOut: 10, dataOutDuration: 1.2, - expectedShards: 1, // no reaction - less than 30% change + expectedShards: 2, // 1.2 is rounded up to 2. }, { name: "bigger slowdown", @@ -1033,7 +1033,7 @@ func TestCalculateDesiredShardsDetail(t *testing.T) { dataIn: 10, dataOut: 10, dataOutDuration: 1.4, - expectedShards: 2, // now it shards up + expectedShards: 2, }, { name: "speed up",