Modify DataRetention behavior; simplify SQL config

This commit is contained in:
Noi 2021-02-01 22:03:50 -08:00
parent 9667820df4
commit 1e8b47784d
2 changed files with 3 additions and 6 deletions

View file

@ -15,7 +15,7 @@ namespace BirthdayBot.BackgroundServices
/// </summary>
class DataRetention : BackgroundService
{
private static readonly SemaphoreSlim _updateLock = new SemaphoreSlim(1);
private static readonly SemaphoreSlim _updateLock = new SemaphoreSlim(2);
const int ProcessInterval = 600 / ShardBackgroundWorker.Interval; // Process every ~10 minutes
private int _tickCount = 0;
@ -35,7 +35,7 @@ namespace BirthdayBot.BackgroundServices
// to avoid putting pressure on the SQL connection pool. Updating this is a low priority.
await _updateLock.WaitAsync(token).ConfigureAwait(false);
}
catch (OperationCanceledException)
catch (Exception ex) when (ex is OperationCanceledException || ex is ObjectDisposedException)
{
// Calling thread does not expect the exception that SemaphoreSlim throws...
throw new TaskCanceledException();

View file

@ -58,10 +58,7 @@ namespace BirthdayBot
{
Host = sqlhost,
Username = sqluser,
Password = sqlpass,
// Note: Npgsql connection pooling settings are defined (hardcoded) here.
MinPoolSize = 3,
MaxPoolSize = 20
Password = sqlpass
};
var sqldb = jc["SqlDatabase"]?.Value<string>();
if (sqldb != null) csb.Database = sqldb; // Optional database setting