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