Skip to content

Commit

Permalink
Little better resiliency on resource setup. Closes GH-522
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Sep 18, 2023
1 parent 6b7400b commit 961d139
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Persistence/Wolverine.RDBMS/MessageDatabase.Admin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Data.Common;
using JasperFx.Core;
using Weasel.Core;
using Wolverine.Logging;

Expand Down Expand Up @@ -49,10 +50,23 @@ public async Task RebuildAsync()

public async Task MigrateAsync()
{
await using var conn = CreateConnection();
await conn.OpenAsync(_cancellation);
Func<Task> tryMigrate = async () =>
{
await using var conn = CreateConnection();
await conn.OpenAsync(_cancellation);

await migrateAsync(conn);
await migrateAsync(conn);
};

try
{
await tryMigrate();
}
catch (Exception)
{
await Task.Delay(new Random().Next(250, 1000).Milliseconds(), _cancellation);
await tryMigrate();
}
}

public async Task<IReadOnlyList<Envelope>> AllIncomingAsync()
Expand Down

0 comments on commit 961d139

Please sign in to comment.