remove locks around metrics for testing, add back dbcontext pooling

This commit is contained in:
Stanley Dimant
2022-08-18 01:17:49 +02:00
parent 077f6f3dc4
commit 54d625e729
5 changed files with 21 additions and 21 deletions

View File

@@ -13,10 +13,10 @@ namespace MareSynchronosServer.Metrics
public void Inc(double inc = 1d)
{
lock (_c)
{
//lock (_c)
//{
_c.Inc(inc);
}
//}
}
}
}

View File

@@ -13,34 +13,34 @@ public class LockedProxyGauge
public void Inc(double inc = 1d)
{
lock (_g)
{
//lock (_g)
//{
_g.Inc(inc);
}
//}
}
public void IncTo(double incTo)
{
lock (_g)
{
//lock (_g)
//{
_g.IncTo(incTo);
}
//}
}
public void Dec(double decBy = 1d)
{
lock (_g)
{
//lock (_g)
//{
_g.Dec(decBy);
}
//}
}
public void Set(double setTo)
{
lock (_g)
{
//lock (_g)
//{
_g.Set(setTo);
}
//}
}
public double Value => _g.Value;

View File

@@ -23,7 +23,7 @@ namespace MareSynchronosServer
using (var scope = host.Services.CreateScope())
{
var services = scope.ServiceProvider;
var context = services.GetRequiredService<MareDbContext>();
using var context = services.GetRequiredService<MareDbContext>();
context.Database.Migrate();
context.SaveChanges();

View File

@@ -1,4 +1,3 @@
using System;
using MareSynchronos.API;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
@@ -13,7 +12,6 @@ using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http.Connections;
using Microsoft.AspNetCore.SignalR;
using Prometheus;
using WebSocketOptions = Microsoft.AspNetCore.Builder.WebSocketOptions;
using Microsoft.Extensions.FileProviders;
using Microsoft.AspNetCore.Authorization;
using MareSynchronosServer.Discord;
@@ -48,13 +46,14 @@ namespace MareSynchronosServer
services.AddSingleton<IUserIdProvider, IdBasedUserIdProvider>();
services.AddTransient(_ => Configuration);
services.AddDbContext<MareDbContext>(options =>
services.AddDbContextPool<MareDbContext>(options =>
{
options.EnableThreadSafetyChecks(false);
options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"), builder =>
{
builder.MigrationsHistoryTable("_efmigrationshistory", "public");
}).UseSnakeCaseNamingConvention();
});
}, Configuration.GetValue("DbContextPoolSize", 1024));
services.AddHostedService<CleanupService>();
services.AddHostedService(provider => provider.GetService<SystemInfoService>());

View File

@@ -23,6 +23,7 @@
]
}
},
"DbContextPoolSize": 2000,
"CdnFullUrl": "https://<url or ip to your server>/cache/",
"FailedAuthForTempBan": 5,
"TempBanDurationInMinutes": 30,