We have an azure websites that is running Hangfire which appears to be deadlocking when we restart.
[SqlException (0x80131904): Transaction (Process ID 1161) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
Installing Hangfire SQL objects...
Database schema [HangFire] already exists
Table [HangFire].[Schema] already exists
Current HangFire schema version: 3]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +1787814
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5341674
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +546
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +1693
System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) +869
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +413
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +163
Dapper.SqlMapper.ExecuteCommand(IDbConnection cnn, CommandDefinition& command, Action`2 paramReader) +93
Dapper.SqlMapper.ExecuteImpl(IDbConnection cnn, CommandDefinition& command) +761
Dapper.SqlMapper.Execute(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Nullable`1 commandTimeout, Nullable`1 commandType) +175
Hangfire.SqlServer.SqlServerObjectsInstaller.Install(SqlConnection connection) +182
Hangfire.SqlServer.SqlServerStorage..ctor(String nameOrConnectionString, SqlServerStorageOptions options) +203
Thunder.Startup.<Configuration>b__2(IBootstrapperConfiguration config) +87
Hangfire.OwinBootstrapper.UseHangfire(IAppBuilder app, Action`1 configurationAction) +82
Thunder.Startup.Configuration(IAppBuilder app) +207
See the full stack trace here
https://jsfiddle.net/np0dc1zm/embedded/result/
We scaled down to just one azure instance and restart and this is no longer an issue. Any idea what is going on?