Merge pull request #426 from Icinga/bugfix/redis-connection-pool-timeout

Make sure Redis connection pool is large enough
This commit is contained in:
Eric Lippmann 2021-12-09 16:09:18 +01:00 committed by GitHub
commit 0f64125af3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View file

@ -8,6 +8,7 @@ import (
"github.com/icinga/icingadb/pkg/icingaredis"
"github.com/icinga/icingadb/pkg/logging"
"github.com/icinga/icingadb/pkg/retry"
"github.com/icinga/icingadb/pkg/utils"
"github.com/pkg/errors"
"go.uber.org/zap"
"net"
@ -54,6 +55,7 @@ func (r *Redis) NewClient(logger *logging.Logger) (*icingaredis.Client, error) {
opts := c.Options()
opts.MaxRetries = opts.PoolSize + 1 // https://github.com/go-redis/redis/issues/1737
opts.PoolSize = utils.MaxInt(32, opts.PoolSize)
c = redis.NewClient(opts)
return icingaredis.NewClient(c, logger, &r.Options), nil

View file

@ -191,3 +191,12 @@ func AppName() string {
return filepath.Base(exe)
}
// MaxInt returns the larger of the given integers.
func MaxInt(x, y int) int {
if x > y {
return x
}
return y
}