# HangFire:recurring-jobs:lock Issue

**URL:** <https://discuss.hangfire.io/t/hangfire-recurring-jobs-lock-issue/4608>\
**Category:** bug?\
**Created:** [April 27, 2018, 2:05pm UTC](https://discuss.hangfire.io/t/hangfire-recurring-jobs-lock-issue/4608 "2018-04-27T14:05:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amshanmugam80](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@amshanmugam80](https://discuss.hangfire.io/u/amshanmugam80)\
**Post date:** [April 27, 2018, 2:05pm UTC](https://discuss.hangfire.io/t/hangfire-recurring-jobs-lock-issue/4608/1 "2018-04-27T14:05:11Z")

</div>

Hi There,  
I have added hangfire netcore packages for scheduling tasks in my [asp.net](http://asp.net) core app. I have given package names and versions below,

**"Hangfire.AspNetCore": "1.6.17"**  
**"Hangfire.PostgreSql": "1.4.8.1"**

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.

**ERROR:**  
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  
WHERE NOT EXISTS (  
SELECT 1 FROM “hangfire”.“lock”  
WHERE “resource” = $1  
)

---

<div class="post-metadata">

**Author:** ![magbeat](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/magbeat/32/2255_2.png) [@magbeat](https://discuss.hangfire.io/u/magbeat)\
**Post date:** [May 17, 2021, 7:51am UTC](https://discuss.hangfire.io/t/hangfire-recurring-jobs-lock-issue/4608/2 "2021-05-17T07:51:01Z")

</div>

Hi there,

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

> <https://github.com/frankhommers/Hangfire.PostgreSql/issues/107>
>
> Hi,
> I'm getting some random errors when inserting in the Lock table.
> at Npgsql.NpgsqlConnector.\<\>c\_\_DisplayClass161\_0.\<\<ReadMessage\>g\_\_ReadMessageLong|0\>d.MoveNext()
> \--- End of stack trace from previous location where exception...

Regards, Markus

---

<div class="post-metadata">

**Author:** ![josofd](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/josofd/32/2566_2.png) [@josofd](https://discuss.hangfire.io/u/josofd)\
**Post date:** [May 24, 2021, 7:53pm UTC](https://discuss.hangfire.io/t/hangfire-recurring-jobs-lock-issue/4608/3 "2021-05-24T19:53:39Z")

</div>

Hi!

We have this issue with two instances on kubernetes.

Regards!
