From 28ec2df70f0732a5e834634d9bc1ab58c96c05ac Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Wed, 21 Oct 2020 07:33:24 +0200 Subject: [PATCH] Limit number of default workers when using SQLite #558 Signed-off-by: Michael Mayer --- internal/config/config.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/config/config.go b/internal/config/config.go index e3c727d17..0748d3dd9 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -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 }