# Batch not changing to finished even when all the jobs are succeeded

**URL:** <https://discuss.hangfire.io/t/batch-not-changing-to-finished-even-when-all-the-jobs-are-succeeded/11096>\
**Category:** bug?\
**Created:** [December 26, 2024, 6:46pm UTC](https://discuss.hangfire.io/t/batch-not-changing-to-finished-even-when-all-the-jobs-are-succeeded/11096 "2024-12-26T18:46:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leonel\_Norat](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/leonel_norat/32/3892_2.png) [@Leonel\_Norat](https://discuss.hangfire.io/u/Leonel_Norat)\
**Post date:** [December 26, 2024, 6:46pm UTC](https://discuss.hangfire.io/t/batch-not-changing-to-finished-even-when-all-the-jobs-are-succeeded/11096/1 "2024-12-26T18:46:24Z")

</div>

I have some issues with the batch function. The batch stays unfinished because the last job remains pending even when the job status is succeeded.  
Anyway to fix this or “force” the batch refreshing of status?

Screenshot:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/hangfire/original/2X/e/e4c77643f02eb715ce7e0e989769941a02160a86.png)  
 ![image](https://europe1.discourse-cdn.com/flex017/uploads/hangfire/original/2X/3/336a423c51be3996676ee57a6044bb54019fc779.png)

---

<div class="post-metadata">

**Author:** ![odinserj](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/odinserj/32/648_2.png) [@odinserj](https://discuss.hangfire.io/u/odinserj)\
**Post date:** [December 27, 2024, 7:18am UTC](https://discuss.hangfire.io/t/batch-not-changing-to-finished-even-when-all-the-jobs-are-succeeded/11096/2 "2024-12-27T07:18:53Z")

</div>

Can you post here your configuration logic related to Hangfire and list all Hangfire-related packages and their versions?

---

<div class="post-metadata">

**Author:** ![Leonel\_Norat](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/leonel_norat/32/3892_2.png) [@Leonel\_Norat](https://discuss.hangfire.io/u/Leonel_Norat)\
**Post date:** [December 27, 2024, 3:17pm UTC](https://discuss.hangfire.io/t/batch-not-changing-to-finished-even-when-all-the-jobs-are-succeeded/11096/3 "2024-12-27T15:17:18Z")

</div>

Packages used in app:

```auto
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.17" />
<PackageReference Include="Hangfire.Core" Version="1.8.17" />
<PackageReference Include="Hangfire.PostgreSql" Version="1.20.9" />
<PackageReference Include="Hangfire.PostgreSql.NetCore" Version="1.4.3" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.17" />
 <PackageReference Include="Hangfire.Core" Version="1.8.17" />
 <PackageReference Include="Hangfire.PostgreSql" Version="1.20.9" />
 <PackageReference Include="Hangfire.PostgreSql.NetCore" Version="1.4.3" />
        

```

In Program.cs:

```auto
// Add Hangfire services.
    GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 0 });
    builder.Services.AddHangfire(configuration => configuration
        .SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
        .UseSimpleAssemblyNameTypeSerializer()
        .UseRecommendedSerializerSettings()
        .UseBatches()
        .UsePostgreSqlStorage(c => c.UseNpgsqlConnection(builder.Configuration.GetConnectionString("HangfireConnection"))));

    // Add the processing server as IHostedService
    var workerProcessorCount = int.TryParse(Environment.GetEnvironmentVariable("WORKER_PROCESSOR_COUNT"), out var count) ? count : 5;
    builder.Services.AddHangfireServer(options =>
    {
        options.WorkerCount = Environment.ProcessorCount * workerProcessorCount;
        options.Queues = ["notifications", "batches", "internaltransfer", "transfers", "operations", "reconciliation", "processfiles", "reports", "default"];
    });

```

---

<div class="post-metadata">

**Author:** ![odinserj](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/odinserj/32/648_2.png) [@odinserj](https://discuss.hangfire.io/u/odinserj)\
**Post date:** [December 28, 2024, 6:39am UTC](https://discuss.hangfire.io/t/batch-not-changing-to-finished-even-when-all-the-jobs-are-succeeded/11096/4 "2024-12-28T06:39:47Z")

</div>

Thanks for the details, @Leonel_Norat! I see you are using a community-based job storage implementation for PostgreSQL. Unfortunately, batches and throttlers use advanced features of a job storage implementation, and may be not compatible with community-based storages, as outlined on the [overview page](https://www.hangfire.io/pro/) and the corresponding [documentation article](https://docs.hangfire.io/en/latest/background-methods/using-batches.html#installation).

Is it possible for you to switch to Hangfire.SqlServer or Hangfire.Pro.Redis instead?

---

<div class="post-metadata">

**Author:** ![Leonel\_Norat](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/leonel_norat/32/3892_2.png) [@Leonel\_Norat](https://discuss.hangfire.io/u/Leonel_Norat)\
**Post date:** [December 30, 2024, 4:34pm UTC](https://discuss.hangfire.io/t/batch-not-changing-to-finished-even-when-all-the-jobs-are-succeeded/11096/5 "2024-12-30T16:34:15Z")

</div>

Thanks, @odinserj. I will look at it. In our current implementation, it is possible to move to Redis.
