Prevent number of remote write shards from going negative.

This can happen in the situation where the system scales up the number of shards massively (to deal with some backlog), then scales it down again as the number of samples sent during the time period is less than the number received.
This commit is contained in:
Tom Wilkie 2017-07-19 16:27:19 +01:00
parent 4d8e7ca185
commit 4f8efdbd59
1 changed files with 2 additions and 0 deletions

View File

@ -339,6 +339,8 @@ func (t *QueueManager) calculateDesiredShards() {
numShards := int(math.Ceil(desiredShards)) numShards := int(math.Ceil(desiredShards))
if numShards > t.cfg.MaxShards { if numShards > t.cfg.MaxShards {
numShards = t.cfg.MaxShards numShards = t.cfg.MaxShards
} else if numShards < 1 {
numShards = 1
} }
if numShards == t.numShards { if numShards == t.numShards {
return return