Limit number of default workers when using SQLite #558

Signed-off-by: Michael Mayer <michael@lastzero.net>
This commit is contained in:
Michael Mayer 2020-10-21 07:33:24 +02:00
parent 458dfcefdc
commit 28ec2df70f

View file

@ -232,6 +232,11 @@ func (c *Config) Shutdown() {
func (c *Config) Workers() int {
numCPU := runtime.NumCPU()
// Limit number of workers when using SQLite to avoid database locking issues.
if c.DatabaseDriver() == SQLite && numCPU > 8 && c.params.Workers <= 0 {
return 8
}
if c.params.Workers > 0 && c.params.Workers <= numCPU {
return c.params.Workers
}