Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deadlock found when trying to get lock; try restarting transaction #2470

Open
srad opened this issue Nov 19, 2024 · 0 comments
Open

Deadlock found when trying to get lock; try restarting transaction #2470

srad opened this issue Nov 19, 2024 · 0 comments

Comments

@srad
Copy link

srad commented Nov 19, 2024

For a while now I get each time I start my server which is running Hangfire immediately following error message:

2024-11-19 09:01:45.0532|0|ERROR|Hangfire.Processing.BackgroundExecution|Execution BackgroundServerProcess is in the Failed state now due to an exception, execution will be retried in no more than 00:00:15 NHibernate.Exceptions.GenericADOException: could not insert: 

[Hangfire.FluentNHibernateStorage.Entities._Server#workstation:8136:836b1a05-468e-48a8-a7de-2beeeec226ac][SQL: INSERT INTO `Hangfire_Server` (`Data`, `LastHeartbeat`, `Id`) VALUES (?, ?, ?)]

 ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Deadlock found when trying to get lock; try restarting transaction  at MySql.Data.MySqlClient.MySqlStream.ReadPacketAsync(Boolean execAsync)
...

This is .net 8 with Hangfire 1.8.15 with MySQL Server 8.4.3-1.el9 and following config:

builder.Services.AddHangfire(configuration => configuration
    .SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
    .UseSimpleAssemblyNameTypeSerializer()
    .UseRecommendedSerializerSettings()
    .UseStorage(FluentNHibernateStorageFactory.For(ProviderTypeEnum.MySQL,
        builder.Configuration.GetConnectionString("HangfireConnection"), new FluentNHibernateStorageOptions
        {
            DistributedLockWaitTimeout = TimeSpan.FromMinutes(30),
            TransactionIsolationLevel = IsolationLevel.Serializable,
            QueuePollInterval = TimeSpan.FromSeconds(15),
            JobExpirationCheckInterval = TimeSpan.FromHours(1),
            CountersAggregateInterval = TimeSpan.FromMinutes(5),
            UpdateSchema = true,
            DashboardJobListLimit = 1000,
            InvisibilityTimeout = TimeSpan.FromHours(12),
            TransactionTimeout = TimeSpan.FromHours(12),
            DefaultSchema = null, // use database provider's default schema,
            TablePrefix = "Hangfire_" // underscore necessary
        })));

There are no open jobs in the queue and I think everything is running fine but I still get every single time this exception.

Anyone knows what's going on here with the lock?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant