Add some more resiliency to DB errors
This commit is contained in:
parent
5b262fdc7b
commit
9282d5e9fb
@ -52,6 +52,9 @@ namespace PluralKit.Bot
|
|||||||
// Ignore "Database is shutting down" error
|
// Ignore "Database is shutting down" error
|
||||||
if (e is PostgresException pe && pe.SqlState == "57P03") return false;
|
if (e is PostgresException pe && pe.SqlState == "57P03") return false;
|
||||||
|
|
||||||
|
// Ignore thread pool exhaustion errors
|
||||||
|
if (e is NpgsqlException npe && npe.Message.Contains("The connection pool has been exhausted")) return false;
|
||||||
|
|
||||||
// This may expanded at some point.
|
// This may expanded at some point.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,10 @@ namespace PluralKit.Core
|
|||||||
|
|
||||||
_connectionString = new NpgsqlConnectionStringBuilder(_config.Database)
|
_connectionString = new NpgsqlConnectionStringBuilder(_config.Database)
|
||||||
{
|
{
|
||||||
Pooling = true, MaxPoolSize = 500, Enlist = false, NoResetOnClose = true
|
Pooling = true, MaxPoolSize = 500, Enlist = false, NoResetOnClose = true,
|
||||||
|
|
||||||
|
// Lower timeout than default (15s -> 2s), should ideally fail-fast instead of hanging
|
||||||
|
Timeout = 2
|
||||||
}.ConnectionString;
|
}.ConnectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user