Skip to content

Login failed for user '<token-identified principal>'. #2554

@mircotoepfer

Description

@mircotoepfer

We are running Hangfire with Azure SQL Database in General Purpose – Serverless configuration.
Under normal operation everything works fine — however:

During scaling down of Azure SQL compute

Hangfire starts producing a massive number of SQL exceptions

Hangfire reports jobs as successfully executed, but their actual code does not run

→ This leads to silently skipped job execution logic, which is a critical reliability issue.

Errors appear in Application Insights, with no immediate application crash.
The behavior suggests Hangfire gets into an inconsistent state while SQL resources are throttled or transitioning.

We suspect Hangfire does not reliably handle transient outage/throttling during scale-down.


Hangfire:

1.8.18 SQL Server (custom) 1.8.18 .NET 9.0

Azure SQL Config:

Service Tier: General Purpose
Computer tier: Serverless
Hardware: Standard-series (Gen5)
MaxVCores: 6
MinVCores: 3

Stack Trace:

[
{
"method": "Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning",
"level": 0,
"line": 0,
"assembly": "Microsoft.Data.SqlClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5"
},
{
"method": "Microsoft.Data.SqlClient.TdsParser.TryRun",
"level": 1,
"line": 0,
"assembly": "Microsoft.Data.SqlClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5"
},
{
"method": "Microsoft.Data.SqlClient.TdsParser.Run",
"level": 2,
"line": 0,
"assembly": "Microsoft.Data.SqlClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5"
},
{
"method": "Microsoft.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin",
"level": 3,
"line": 0,
"assembly": "Microsoft.Data.SqlClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5"
},
{
"method": "Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover",
"level": 4,
"line": 0,
"assembly": "Microsoft.Data.SqlClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5"
},
{
"method": "Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist",
"level": 5,
"line": 0,
"assembly": "Microsoft.Data.SqlClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5"
},
{
"method": "Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor",
"level": 6,
"line": 0,
"assembly": "Microsoft.Data.SqlClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5"
},
{
"method": "Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection",
"level": 7,
"line": 0,
"assembly": "Microsoft.Data.SqlClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5"
},
{
"method": "Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject",
"level": 8,
"line": 0,
"assembly": "Microsoft.Data.SqlClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5"
},
{
"method": "Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest",
"level": 9,
"line": 0,
"assembly": "Microsoft.Data.SqlClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5"
},
{
"method": "Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection",
"level": 10,
"line": 0,
"assembly": "Microsoft.Data.SqlClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5"
},
{
"method": "Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection",
"level": 11,
"line": 0,
"assembly": "Microsoft.Data.SqlClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5"
},
{
"method": "Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal",
"level": 12,
"line": 0,
"assembly": "Microsoft.Data.SqlClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5"
},
{
"method": "Microsoft.Data.SqlClient.SqlConnection.TryOpen",
"level": 13,
"line": 0,
"assembly": "Microsoft.Data.SqlClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5"
},
{
"method": "Microsoft.Data.SqlClient.SqlConnection.Open",
"level": 14,
"line": 0,
"assembly": "Microsoft.Data.SqlClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5"
},
{
"method": "Hangfire.SqlServer.SqlServerStorage.CreateAndOpenConnection",
"level": 15,
"line": 393,
"assembly": "Hangfire.SqlServer, Version=1.8.18.0, Culture=neutral, PublicKeyToken=null",
"fileName": "C:\projects\hangfire-525\src\Hangfire.SqlServer\SqlServerStorage.cs"
},
{
"method": "Hangfire.SqlServer.SqlServerConnection.AcquireLock",
"level": 16,
"line": 800,
"assembly": "Hangfire.SqlServer, Version=1.8.18.0, Culture=neutral, PublicKeyToken=null",
"fileName": "C:\projects\hangfire-525\src\Hangfire.SqlServer\SqlServerConnection.cs"
},
{
"method": "Hangfire.States.BackgroundJobStateChanger.ChangeState",
"level": 17,
"line": 61,
"assembly": "Hangfire.Core, Version=1.8.18.0, Culture=neutral, PublicKeyToken=null",
"fileName": "C:\projects\hangfire-525\src\Hangfire.Core\States\BackgroundJobStateChanger.cs"
},
{
"method": "Hangfire.Server.Worker.TryChangeState",
"level": 18,
"line": 235,
"assembly": "Hangfire.Core, Version=1.8.18.0, Culture=neutral, PublicKeyToken=null",
"fileName": "C:\projects\hangfire-525\src\Hangfire.Core\Server\Worker.cs"
}
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions