# Best Practices for Retrying a Large Number of Jobs (128,000+) in Camunda

**URL:** <https://forum.camunda.io/t/best-practices-for-retrying-a-large-number-of-jobs-128-000-in-camunda/54286>\
**Category:** Discussion & Questions\
**Tags:** process-engine, spring-boot-starter, cockpit\
**Created:** [August 17, 2024, 5:58pm UTC](https://forum.camunda.io/t/best-practices-for-retrying-a-large-number-of-jobs-128-000-in-camunda/54286 "2024-08-17T17:58:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pertsh.galstyan](https://forum.camunda.io/user_avatar/forum.camunda.io/pertsh.galstyan/32/27321_2.png) [@pertsh.galstyan](https://forum.camunda.io/u/pertsh.galstyan)\
**Post date:** [August 17, 2024, 5:58pm UTC](https://forum.camunda.io/t/best-practices-for-retrying-a-large-number-of-jobs-128-000-in-camunda/54286/1 "2024-08-17T17:58:07Z")

</div>

I’m currently dealing with a significant challenge in our Camunda setup. We have around **128,000** failed jobs that need to be retried. I am looking for advice on the most efficient and reliable way to handle this situation.

---

<div class="post-metadata">

**Author:** ![WilliamR.Alves](https://forum.camunda.io/user_avatar/forum.camunda.io/williamr.alves/32/27412_2.png) [@WilliamR.Alves](https://forum.camunda.io/u/WilliamR.Alves)\
**Post date:** [August 20, 2024, 3:16am UTC](https://forum.camunda.io/t/best-practices-for-retrying-a-large-number-of-jobs-128-000-in-camunda/54286/2 "2024-08-20T03:16:17Z")

</div>

Hello my friend!

I see that you really had a big problem, huh! 🥶

I believe that there is not much “magic” that we can do in this case, unfortunately…

I think that the best thing to do is to create a script to search for failed jobs, and execute them in batches, little by little, with a quantity of executions and timeout appropriate for the power of your application, and wait until this script executes everything.

I suggest that this be done at a time when your application has few executions in progress, since retry uses job executors for execution.

**William Robert Alves**

---

<div class="post-metadata">

**Author:** ![pertsh.galstyan](https://forum.camunda.io/user_avatar/forum.camunda.io/pertsh.galstyan/32/27321_2.png) [@pertsh.galstyan](https://forum.camunda.io/u/pertsh.galstyan)\
**Post date:** [August 21, 2024, 7:57am UTC](https://forum.camunda.io/t/best-practices-for-retrying-a-large-number-of-jobs-128-000-in-camunda/54286/3 "2024-08-21T07:57:18Z")

</div>

Would it be feasible to solve this issue using a SQL script? For example, we could use a query that resets the retry count for failed jobs from 0 to 1. Here’s a possible script:

```auto
WITH cte AS (
    SELECT job.id_
    FROM act_ru_job job
    WHERE job.retries_ = 0
      AND job.lock_owner_ IS NULL
      AND job.process_def_id_ = 'RefundRetryProcess:7:3d65d061-9d93-11ee-b00f-d6037865158d'
    LIMIT 1000
)
UPDATE act_ru_job job
SET retries_ = 1,
    duedate_ = NOW()
FROM cte
WHERE job.id_ = cte.id_;

```

---

<div class="post-metadata">

**Author:** ![Alex\_Voloshyn](https://forum.camunda.io/user_avatar/forum.camunda.io/alex_voloshyn/32/14765_2.png) [@Alex\_Voloshyn](https://forum.camunda.io/u/Alex_Voloshyn)\
**Post date:** [August 21, 2024, 8:49am UTC](https://forum.camunda.io/t/best-practices-for-retrying-a-large-number-of-jobs-128-000-in-camunda/54286/4 "2024-08-21T08:49:26Z")

</div>

Hi @pertsh.galstyan  
I would avoid any direct intervention in the database and suggest you to take a look at this REST API: [Camunda Automation Platform 7.20.7 REST API](https://docs.camunda.org/rest/camunda-bpm-platform/7.20/#tag/Process-Instance/operation/setRetriesByProcess). to set retries.
