diff --git a/PluralKit.Bot/Utils/MiscUtils.cs b/PluralKit.Bot/Utils/MiscUtils.cs index 96e7d7cb..4ce4b24c 100644 --- a/PluralKit.Bot/Utils/MiscUtils.cs +++ b/PluralKit.Bot/Utils/MiscUtils.cs @@ -52,6 +52,9 @@ namespace PluralKit.Bot // Ignore "Database is shutting down" error 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. return true; } diff --git a/PluralKit.Core/Database/Database.cs b/PluralKit.Core/Database/Database.cs index bfa66101..aea4f6fe 100644 --- a/PluralKit.Core/Database/Database.cs +++ b/PluralKit.Core/Database/Database.cs @@ -37,7 +37,10 @@ namespace PluralKit.Core _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; }