Skip to content

fix: TrimList keeps newest list entries by ordering id DESC#426

Open
avve wants to merge 1 commit into
hangfire-postgres:masterfrom
avve:fix/trimlist-order-desc
Open

fix: TrimList keeps newest list entries by ordering id DESC#426
avve wants to merge 1 commit into
hangfire-postgres:masterfrom
avve:fix/trimlist-order-desc

Conversation

@avve

@avve avve commented Apr 9, 2026

Copy link
Copy Markdown

Bug: TrimList keeps oldest list entries instead of newest

Problem

The number of batches that are listed in the hangfire dashboard is limited by the maxListEntries setting that can be passed to UseBatches

config.AddHangfire(config =>
{
   // ...
   config.UseBatches(expirationTime: TimeSpan.FromDays(1), maxListEntries: 100, filterProvider: JobFilterProviders.Providers);
}

The TrimList method in PostgreSqlWriteOnlyTransaction is used to reduce the number of batch entries in the hangfire.list table to this limit. The current implementation is using a query where we order by id. It should be the ORDER BY ""id"" DESC otherwise we will always keep the oldest n batch entries instead of the newest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant