Friday, 8 June 2012

Expired sessions are not being deleted from the ASP.NET Session State database

Expired sessions are not being deleted from the ASP.NET Session State database

Sometimes you get this in Health Analyser and this one doesn't have an automatic repair option.

Here is how you can fix this:

There is a timer job called State Service Delete Expired Sessions

Run this manually

Give it 5 minutes and refresh the central admin the warning/error should not be there

Please note this job is set to run every hour unless the scheduled has been altered.

If that doesn't work, launch the SQL Server Management Studio
Connect to Your Database Engine
Select State Service Database (you will have proper name if your have taken care off the GUID while provisioning the State Service App or else stateservice_someguid)

Run this query to see any expired sessions

Select * from session against the State Service Database

If  any, run the procedure to clear this: proc_DeleteExpiredItems

Make sure SQL Server Agent is started

You can also create a job as a part of maintenance plan  in SQL Server if required to automate it but the timer job is there to handle this.

3 comments:

  1. Admiring the hard work you put into your website and in depth information you offer.

    It's awesome to come across a blog every once in a while that isn't the same old rehashed material.
    Great read! I've saved your site and I'm adding your RSS
    feeds to my Google account.
    Feel free to visit my blog - historical weather

    ReplyDelete
  2. For "ASP.NET Session State database" the right table is [ASPStateTempSessions] and the proper Stored Procedure would be "DeleteExpiredSessions". Depending on how it was created, the name of te Database would be "...SessionStateServiceDB" compared to the "...StateServiceDB" which is usually created by the SharePoint Configuration Wizard.

    ReplyDelete
  3. Thanks surfkid,
    Your solution solved my issue of Asp.net expiry sessions.

    ReplyDelete