diff --git a/src/Persistence/Wolverine.RDBMS/MessageDatabase.Admin.cs b/src/Persistence/Wolverine.RDBMS/MessageDatabase.Admin.cs index 476aa07c9..ac9b9b799 100644 --- a/src/Persistence/Wolverine.RDBMS/MessageDatabase.Admin.cs +++ b/src/Persistence/Wolverine.RDBMS/MessageDatabase.Admin.cs @@ -1,4 +1,5 @@ using System.Data.Common; +using JasperFx.Core; using Weasel.Core; using Wolverine.Logging; @@ -49,10 +50,23 @@ public async Task RebuildAsync() public async Task MigrateAsync() { - await using var conn = CreateConnection(); - await conn.OpenAsync(_cancellation); + Func 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> AllIncomingAsync()