# Job expiration not respected?

**URL:** <https://discuss.hangfire.io/t/job-expiration-not-respected/1180>\
**Category:** bug?\
**Created:** [July 30, 2015, 9:07am UTC](https://discuss.hangfire.io/t/job-expiration-not-respected/1180 "2015-07-30T09:07:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AdityaSantoso](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@AdityaSantoso](https://discuss.hangfire.io/u/AdityaSantoso)\
**Post date:** [July 30, 2015, 9:07am UTC](https://discuss.hangfire.io/t/job-expiration-not-respected/1180/1 "2015-07-30T09:07:03Z")

</div>

I am using the default SQL Server storage for Hangfire. Since the rate of job creation per-day can be quite high (in the count of hundreds of thousands), the size of the database also grows quite fast.

Initially I thought it will still be fine because Succeeded jobs would be removed after one day. To my surprise, even after several days, the job is not yet removed from Hangfire.Jobs table.

When I ran this query on 30 July 2015:

```
select min(ExpireAt) from Hangfire.Job
where StateName = 'Succeeded' 

```

I got `2015-07-21 13:28:27.543`, which is about 9 days ago.

I can manually delete the jobs myself or create a batch job that would periodically clean it up, but is there any scenario where the Succeeded job are still retained beyond their `ExpireAt`?

---

<div class="post-metadata">

**Author:** ![AdityaSantoso](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@AdityaSantoso](https://discuss.hangfire.io/u/AdityaSantoso)\
**Post date:** [August 1, 2015, 8:22am UTC](https://discuss.hangfire.io/t/job-expiration-not-respected/1180/2 "2015-08-01T08:22:09Z")

</div>

For illustration. The job was expired 11 days ago, yet it still can be loaded in the dashboard?

 ![](https://europe1.discourse-cdn.com/flex017/uploads/hangfire/original/1X/aaff7d80c78b2e831849ac33abce2754379cfac5.jpg)

---

<div class="post-metadata">

**Author:** ![odinserj](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/odinserj/32/648_2.png) [@odinserj](https://discuss.hangfire.io/u/odinserj)\
**Post date:** [August 4, 2015, 1:14pm UTC](https://discuss.hangfire.io/t/job-expiration-not-respected/1180/3 "2015-08-04T13:14:52Z")

</div>

Is there any active server? Looks like the `ExpirationManager` component is not working due to some exception. Please [enable logging](http://docs.hangfire.io/en/latest/configuration/configuring-logging.html) to get more details.

---

<div class="post-metadata">

**Author:** ![AdityaSantoso](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@AdityaSantoso](https://discuss.hangfire.io/u/AdityaSantoso)\
**Post date:** [August 5, 2015, 2:30am UTC](https://discuss.hangfire.io/t/job-expiration-not-respected/1180/4 "2015-08-05T02:30:25Z")

</div>

There is active server, although the server does got rebooted and new code deployed several times. Does it affect the `ExpirationManager`?

---

<div class="post-metadata">

**Author:** ![odinserj](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/odinserj/32/648_2.png) [@odinserj](https://discuss.hangfire.io/u/odinserj)\
**Post date:** [August 5, 2015, 1:41pm UTC](https://discuss.hangfire.io/t/job-expiration-not-respected/1180/5 "2015-08-05T13:41:41Z")

</div>

You can check whether ExpirationManager is working, just check the lowest HangFire.Job.Id column value. If it is increasing, then expiration manager does not remove jobs in time. Can you verify this?
