Open jeffsugden opened 8 years ago
So what happens with the network on that instance? I'm unsure whether it helps, if I add an immediate retry logic in case of an exception to the Hangfire code base. You also can set the SqlServerStorageOptions.PrepareSchemaIfNecessary
property to false
, and use SqlServerObjectsInstaller
class manually:
using (var connection = CreateAndOpenConnection())
{
SqlServerObjectsInstaller.Install(connection, options.SchemaName);
}
This Sql Server is at a remote location across a VPN link. The network outages that we have measured last several minutes, so an immediate retry would not help there.
I updated the application to use with SqlServerStorageOptions.PrepareSchemaIfNecessary
property set to false
. Testing confirms that this does allow the AppDomain to start properly, so the application does not hang. That will be good enough for the needs of this application, I will just make a note to do any schema update(s) manually for future updates.
Would it be beneficial to allow Hangfire to defer the database schema initialization if it fails, and continue to try the initialization in the background? This way the AppDomain could at least start properly. Though I suspect that it may be difficult implement in that way.
I have a similar issue to this (might be the same). I have followed the guide for Auto-Start, and that's working great, but if the SQL Server just happens to be down/unreachable at the time the App Pool is recycling, the App Pool will crash. This brings down the website until I manually log onto the web server and restart the App Pool.
Is using the "PrepareSchemaIfNecessary" option still the best solution?
Attached is a copy of the XML event from the windows event viewer. Here is a SS for a quick glance (otherwise click the link for the *.TXT file after). HangfireSQLStartupInPreloadError.txt
Is there any update on this yet? We have an Azure SQL instance set up for our staging server which will shut down after an extended period of inactivity and wake back up when needed. This cold start delay seems to cause hangfire to throw an error on startup and lock our application in an error state until we manually restart it. Is there some way we can configure this so that if it fails it doesn't prevent the application from starting and can then just periodically retry (ie with an exponential backoff) in the background?
We are facing a similar issue. The application hangs and everytime hangfire tries to queue a bg job, we get the same errors. Restarting the app fixes the issue - until it occurs again.
This issue occurs on startup when using the SqlServer storage package on a web application hosted on IIS. If the Sql Server connection fails for any reason, the Hangfire initialization procedure throws an exception and the application hangs.
Because the exception occurs during startup, the application will remain in this error state until the AppDomain is restarted, which we normally have to do by manually resetting the appPool in IIS.
Here is a stacktrace showing where the exception occurs, taken by temporary disconnecting the instance from the network.
Statup.cs:
Hangfire Versions: Core 1.5.4.0 SqlServer 1.5.4.0 Windows Server 2012 R2 IIS 8.5
Also it looks like issue may be related: https://github.com/HangfireIO/Hangfire/issues/273