imranmomin / Hangfire.AzureCosmosDb

Azure Cosmos DB storage provider for Hangfire
https://www.hangfire.io/
MIT License
17 stars 16 forks source link

Expired Job States not being cleaned up #29

Closed bzumhagen closed 2 years ago

bzumhagen commented 3 years ago

Right now when a job is expired, only the job is being cleaned up, not the associated job states.

It looks like in the SQL implementation they rely on the fact that state is a foreign key and therefore when you delete the job it also deleted the associated state.

See: https://discuss.hangfire.io/t/hangfire-database-size/791.

So I think we need to update the query here: https://github.com/imranmomin/Hangfire.AzureCosmosDb/blob/develop/src/CosmosDbWriteOnlyTransaction.cs#L133 to include adding the expire_on field to state records for a job.

Then add state to the types of documents expired: https://github.com/imranmomin/Hangfire.AzureCosmosDb/blob/develop/src/ExpirationManager.cs#L21

I added a PR which I think resolves this.

See: https://github.com/imranmomin/Hangfire.AzureCosmosDb/pull/30