Skip to content

Commit 227a5e7

Browse files
sbidoulthomaspaulb
authored andcommitted
[IMP] queue_job: take weaker locks
Since we are not going to delete records nor modify foreign keys, we can take a weaker lock.
1 parent afc351c commit 227a5e7

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

queue_job/controllers/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def _acquire_job(cls, env: api.Environment, job_uuid: str) -> Job | None:
4040
"""
4141
env.cr.execute(
4242
"SELECT uuid FROM queue_job WHERE uuid=%s AND state=%s "
43-
"FOR UPDATE SKIP LOCKED",
43+
"FOR NO KEY UPDATE SKIP LOCKED",
4444
(job_uuid, ENQUEUED),
4545
)
4646
if not env.cr.fetchone():

queue_job/job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def lock(self) -> bool:
278278
uuid = %s
279279
AND state = %s
280280
)
281-
FOR UPDATE SKIP LOCKED;
281+
FOR NO KEY UPDATE SKIP LOCKED;
282282
""",
283283
[self.uuid, STARTED],
284284
)

queue_job/jobrunner/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def _query_requeue_dead_jobs(self):
371371
queue_job_lock
372372
WHERE
373373
queue_job_lock.queue_job_id = queue_job.id
374-
FOR UPDATE SKIP LOCKED
374+
FOR NO KEY UPDATE SKIP LOCKED
375375
)
376376
OR NOT EXISTS (
377377
SELECT

test_queue_job/tests/test_requeue_dead_job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def get_locks(self, uuid, cr=None):
3535
WHERE
3636
uuid = %s
3737
)
38-
FOR UPDATE SKIP LOCKED
38+
FOR NO KEY UPDATE SKIP LOCKED
3939
""",
4040
[uuid],
4141
)

0 commit comments

Comments
 (0)