Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Feb 24, 2024
1 parent b643c56 commit 90fed7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/BUTR.CrashReportServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public static IHostBuilder CreateHostBuilder(string[] args) => Host
.CreateDefaultBuilder(args)
.ConfigureServices((ctx, services) =>
{
services.Configure<HostOptions>(hostOptions =>
{
hostOptions.BackgroundServiceExceptionBehavior = BackgroundServiceExceptionBehavior.Ignore;
});

if (ctx.Configuration.GetSection("Oltp") is { } oltpSection)
{
var openTelemetry = services.AddOpenTelemetry()
Expand Down
10 changes: 5 additions & 5 deletions src/BUTR.CrashReportServer/Services/DatabaseMigrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ protected override async Task ExecuteAsync(CancellationToken ct)

const int take = 10000;

var idDataCount = sqlite.Set<IdEntity>().Count();
var idDataCount = sqlite.Set<IdEntity>().AsNoTracking().Count();
for (var i = 0; i < idDataCount % take; i+= take)
{
var data = await sqlite.Set<IdEntity>().OrderBy(x => x.FileId).Skip(i * take).Take(take).AsAsyncEnumerable()
var data = await sqlite.Set<IdEntity>().AsNoTracking().OrderBy(x => x.FileId).Skip(i * take).Take(take).AsAsyncEnumerable()
.Select(x => x with
{
Created = DateTime.SpecifyKind(x.Created, DateTimeKind.Utc)
Expand All @@ -47,15 +47,15 @@ protected override async Task ExecuteAsync(CancellationToken ct)
await postgres.SaveChangesAsync(ct);
}

var fileDataCount = sqlite.Set<FileEntity>().Count();
var fileDataCount = sqlite.Set<FileEntity>().AsNoTracking().Count();
for (var i = 0; i < fileDataCount % take; i+= take)
{
var data = await sqlite.Set<FileEntity>().OrderBy(x => x.Id.FileId).Skip(i * take).Take(take).ToArrayAsync(ct);
var data = await sqlite.Set<FileEntity>().AsNoTracking().OrderBy(x => x.Id.FileId).Skip(i * take).Take(take).ToArrayAsync(ct);
await postgres.Set<FileEntity>().AddRangeAsync(data, ct);
await postgres.SaveChangesAsync(ct);
}

var jsonDataCount = sqlite.Set<OldJsonEntity>().Count();
var jsonDataCount = sqlite.Set<OldJsonEntity>().AsNoTracking().Count();
for (var i = 0; i < jsonDataCount % take; i+= take)
{
var data = await sqlite.Set<OldJsonEntity>().OrderBy(x => x.Id.FileId).Skip(i * take).Take(take).AsAsyncEnumerable()
Expand Down

0 comments on commit 90fed7d

Please sign in to comment.