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

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:


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

Packages used in app:

<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:

// 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"];
    });

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 and the corresponding documentation article.

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

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