HangFire:recurring-jobs:lock Issue

Hi There,
I have added hangfire netcore packages for scheduling tasks in my asp.net core app. I have given package names and versions below,

"Hangfire.AspNetCore": "1.6.17"
"Hangfire.PostgreSql": ""

My app is hosted multiple server but hangfire postgres database is sharing by all my apps. I am getting this below issue in my logs files always. I don’t have any idea and please help me to solve this issue.

sql_error_code = 23505 ERROR: duplicate key value violates unique constraint “lock_resource_key”
sql_error_code = 23505 DETAIL: Key (resource)=(HangFire:recurring-jobs:lock) already exists.
sql_error_code = 23505 STATEMENT:
INSERT INTO “hangfire”.“lock”(“resource”, “acquired”)
SELECT $1, $2
SELECT 1 FROM “hangfire”.“lock”
WHERE “resource” = $1

Hi there,

we have the same issue. There is also a Github Issue on the Issue:

Regards, Markus

1 Like


We have this issue with two instances on kubernetes.