raisedapp / Hangfire.Storage.SQLite

An Alternative SQLite Storage for Hangfire
https://www.nuget.org/packages/Hangfire.Storage.SQLite
MIT License
155 stars 31 forks source link

.net 6 Hangfire.Storage.SQLite.SQLiteDistributedLock #51

Closed kevinperezbancoserfinanza closed 10 months ago

kevinperezbancoserfinanza commented 2 years ago

Category: Hangfire.Storage.SQLite.SQLiteDistributedLock EventId: 0

Unable to update heartbeat on the resource 'HangFire:job:1201:state-lock'. The resource is not locked or is locked by another owner.

Category: Hangfire.Storage.SQLite.SQLiteDistributedLock EventId: 0

Unable to update heartbeat on the resource 'HangFire:job:1199:state-lock'. The resource is not locked or is locked by another owner.

Category: Hangfire.Storage.SQLite.SQLiteDistributedLock EventId: 0

Unable to update heartbeat on the resource 'HangFire:job:1199:state-lock'. The resource is not locked or is locked by another owner.

How fix this error?

kevinperezbancoserfinanza commented 2 years ago

in .net core 2.1, 2.2 no occurs this error. Only in .net 6

tomasfil commented 1 year ago

I have the same issue, any other fix than migrating to SQL Server 2022 Express?

SignorLuigi commented 1 year ago

I am using it with .Net 7 and I don't have this problem, is there a way to see your source code? Thanks

tomasfil commented 1 year ago

Unfortunately I cannot share repository, since it is corporate software. I am only using AddOrUpdate scheduled tasks, which .Enqueue anither tasks.

I have 3 scheduled tasks

One will every minute Enqueue approx another 53.

And the other two run once a day at midnight.

It just sometimes happen and sometimes dont.

But all still seem working, maybe it should be warning and not error?

tomasfil commented 1 year ago

Okay, it originates from here. It seems the whole code in that file is not thread safe: https://github.com/raisedapp/Hangfire.Storage.SQLite/blob/32b31a525678efd0431845d3195217c02bda6fcc/src/main/Hangfire.Storage.SQLite/SQLiteDistributedLock.cs#L233

kalai-logicsoft commented 1 year ago

We are also having same problem, almost same situation, like one recurring job enquing multiple background jobs

We are using, Hangfire -1.7.32 Hangfire.Storage.SQLite - 0.3.3

felixclase commented 10 months ago

Fixed it with version 0.4.0 of the library.