Regarding Duende Token Clean Up Job: Duende.IdentityServer.EntityFramework.TokenCleanupService #205
Replies: 5 comments
-
When enabled, the cleanup service should run on the configured interval. The first time it runs, the delay is slightly different because of fuzzing being applied (if configured), but each subsequent run happens on the interval defined in the The Are you hosting IdentityServer as an Azure Function, Azure App Service or another kind of hosted service which isn't configured to be "always on" by any chance? The IdentityServer host needs to be running to ensure the cleanup service regularly performs its task. |
Beta Was this translation helpful? Give feedback.
-
Our Identity Server instances are deployed on AWS EC2. On our end, it's a multi-tenant application, meaning multiple tenants are using the same instance of the application. The Identity Server instance is always available, which is why we're trying to understand the inconsistency in the Duende Token Cleanup job. Despite the instance being up continuously, the cleanup job does not run consistently. As I mentioned earlier, the job appears to run approximately every 8–10 days. When it does run, it cleans up a large number of expired tokens, but then it stops running again. Meanwhile, expired tokens continue to accumulate in the database. I've already shared the configured schedule for the Duende Token Cleanup job. We’re trying to understand why it’s not executing regularly despite the server being always available. |
Beta Was this translation helpful? Give feedback.
-
@wcabus |
Beta Was this translation helpful? Give feedback.
-
Could you temporarily change the log levels to gain more debug data? This would help us in seeing when or if the cleanup host service starts its cleanup tasks, and if any issues are being logged while doing so. If you're using Serilog, these are the log levels to use:
Please ensure to sanitize any log output before posting it here. We're specifically looking for log lines containing:
|
Beta Was this translation helpful? Give feedback.
-
Thank you for your response. I’ll review it to see if the suggested approach is feasible on our end. Most likely, we’ll proceed with your recommendations and will share further updates accordingly. Thanks again! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Which version of Duende IdentityServer are you using?
7.0.8
Which version of .NET are you using?
8.0
I have a few questions regarding the Token Cleanup Service—specifically how it works and its behavior, based on what I’ve observed in the code. here
From my understanding:
The job runs in batches and continues until all expired records are deleted.
However, in the documentation, the TokenCleanupBatchSize property is described as the "number of records," which seems a bit misleading. Based on the code, it appears to define the batch size, not the total number of records to delete.
This suggests that the cleanup job is scheduled to run every hour, deleting expired grants in batches of 100.
However, after reviewing our application logs, it seems the job is not running consistently on a daily basis. We're also unsure about the exact time the job is triggered. In production, we often accumulate millions of expired records, and since the job doesn’t run regularly, our database size increases significantly. From observation, it seems the job runs only once every 7–10 days, which leads to a large backlog of expired records.
Could you please help clarify the following:
Any insights or recommendations to improve the reliability of this process would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions