#2585·Hangfire

Errors when starting Hangfire with SQLServer 2025

Author: vvdb-architectureCreated Aug 3, 2026Updated Aug 8, 2026

Hello,

On Hangfire version 1.8.24 connecting to an SQL 2025 database (17.0.4020.2), where the objects in the corresponding install.sql script have been correctly created (all the tables and all the indexes in install.sql are present), I get the errors reproduced below. I know there are other issues talking about the same problem. But I tried everything and the error happens even when the tables are empty (no point in rebuilding), and even after deleting and recreating the entire Hangfire tables. In fact, it's the same error but for the Jobs, List, Set, and Hash tables. The one for 'Job' is shown here:

[13:15:05 ERR] Error occurred while cleaning up the 'Job' table: Query processor could not produce a query plan because of the hints defined in this query. Resubmit the query without specifying any hints and without using SET FORCEPLAN.
 Microsoft.Data.SqlClient.SqlException (0x80131904): Query processor could not produce a query plan because of the hints defined in this query. Resubmit the query without specifying any hints and without using SET FORCEPLAN.
    at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
    at Microsoft.Data.SqlClient.Connection.SqlConnectionInternal.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
    at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, SqlCommand command, Boolean callerHasConnectionLock, Boolean asyncClose)
    at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
    at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
    at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean isRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
    at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& executeTask, Boolean& usedCache, Boolean asyncWrite, Boolean isRetry, String method)
    at Microsoft.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean isRetry, String methodName)
    at Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery()
    at Hangfire.SqlServer.ExpirationManager.ExecuteNonQuery(DbConnection connection, String commandText, Int32 numberOfRecordsInSinglePass, Action`1 additionalActions, CancellationToken cancellationToken) in C:\projects\hangfire-525\src\Hangfire.SqlServer\ExpirationManager.cs:line 241
    at Hangfire.SqlServer.ExpirationManager.<>c__DisplayClass13_0.<CleanupTable>b__0(DbConnection connection) in C:\projects\hangfire-525\src\Hangfire.SqlServer\ExpirationManager.cs:line 134
    at Hangfire.SqlServer.ExpirationManager.<>c__14`1.<UseConnectionDistributedLock>b__14_0(SqlServerStorage _, DbConnection connection, Func`2 ctx) in C:\projects\hangfire-525\src\Hangfire.SqlServer\ExpirationManager.cs:line 158
    at Hangfire.SqlServer.SqlServerStorage.UseConnection[TContext,TResult](DbConnection dedicatedConnection, Func`4 func, TContext context) in C:\projects\hangfire-525\src\Hangfire.SqlServer\SqlServerStorage.cs:line 292
    at Hangfire.SqlServer.ExpirationManager.UseConnectionDistributedLock[T](SqlServerStorage storage, Func`2 action) in C:\projects\hangfire-525\src\Hangfire.SqlServer\ExpirationManager.cs:line 152
    at Hangfire.SqlServer.ExpirationManager.CleanupTable(SqlServerStorage storage, String query, String table, Int32 numberOfRecordsInSinglePass, CancellationToken cancellationToken, Action`1 additionalActions) in C:\projects\hangfire-525\src\Hangfire.SqlServer\ExpirationManager.cs:line 128
    at Hangfire.SqlServer.ExpirationManager.ExecuteCore(SqlServerStorage storage, CancellationToken cancellationToken) in C:\projects\hangfire-525\src\Hangfire.SqlServer\ExpirationManager.cs:line 94
 ClientConnectionId:c82823d4-1a3c-4b74-9396-4b3525b89a6f
 Error Number:8622,State:1,Class:16

Is there a workaround for this? If it's some kind of cleanup operation, does this mean that Hangfire will not be functionally affected (except that the aforementioned tables won't be cleaned up)?