HangfireIO / Hangfire

An easy way to perform background job processing in .NET and .NET Core applications. No Windows Service or separate process required
https://www.hangfire.io
Other
9.43k stars 1.7k forks source link

Add retry to DB schema/tables initialization #2440

Open joedyndale opened 2 months ago

joedyndale commented 2 months ago

Currently, the DB schema and tables are attempted created on service start. However, there's no retries on this process. For example, when running a service using .NET Aspire, the service always fails to initialize the schema/tables and establish a connection to the DB because the database isn't quite ready yet. The logs just say something about the connection being successful, but failing on pre-handshake. If I, in the Program.cs file add a 10-second delay before configuring the IServiceCollection, the service is able to create the schema/tables and establish the connection just fine. It would be nice not to have such a delay on startup of the service, and instead have Hangfire initialization at least try a few times if a connection can't immediately be established.

.NET 8 Hangfire 1.8.14 Aspire 8.2.0 MacOS 14.6.1