Sitecore 9 slow login – clean up your tickets

We noticed that the login on our CM was degrading, but with no real changes that we thought may affect this.  At it’s worst it was taking up to 45 seconds to login successfully. I  did a quick profile to see what was going on.  Lo and behold a lot of time was being spent hitting the core db looking for existing login tickets, which allows for the remember me functionality to work.

Upon investigating there were LOTS of tickets in the properties table of the core db.  A quick google led me to some older but helpful posts including: https://blog.coates.dk/2016/05/11/sitecore-client-and-logon-is-very-slow-properties-table-again/

As mentioned in this post, there is an agent that is supposed to clean up the tickets once expired, but clearly something was going amiss.  I was able to confirm the CleanupAuthenticationTicketsAgent was running, however it was never picking up any tickets for cleanup.

ManagedPoolThread #2 12:04:16 INFO  Job started: Sitecore.Tasks.CleanupAuthenticationTicketsAgent
ManagedPoolThread #2 12:04:16 INFO  CleanupAuthenticationTicketsAgent: Number of expired authentication tickets that have been removed: 0
ManagedPoolThread #2 12:04:16 INFO  CleanupAuthenticationTicketsAgent: Total number of authentication tickets to process: 0
ManagedPoolThread #2 12:04:16 INFO  Job ended: Sitecore.Tasks.CleanupAuthenticationTicketsAgent (units processed: )

There were definitely tickets that should have expired, so I hit up Sitecore support for some insight.  As it turns out, this is a known bug in 9.0.1 and 9.0.2 as outlined at https://github.com/SitecoreSupport/Sitecore.Support.223702 .  Before installing the patch though, we manually cleared out really old tokens in SQL.

-- EG. This will delete all tickets generated in Dec 2018.  
-- Adjust the date string to suit your needs. Be careful :D

USE {core_database_name};
DELETE
    FROM [dbo].[Properties]
    WHERE [dbo].[Properties].[Key] like '%SC_TICKET%'
    AND [dbo].[Properties].[Value] like '%^201812%';

This had an immediate positive impact to login performance, jumping down to a second or two.

The patch has since been installed and tickets are getting cleaned up happily as reported in the logs.  Happy days.  As always check with support first before installing any patches that may not be appropriate for your specific environment.

 

One thought on “Sitecore 9 slow login – clean up your tickets

  1. Seem to have lost my last comment. 😦

    Anyway was just mentioning that I put together a SQL script for this task that’s a bit more granular, so if you’ve arrived here from Stack Exchange (as I did) then I’m sending you right back again.

    https://sitecore.stackexchange.com/a/20174/131

    Note that you should resist the temptation to truncate the Properties table as there are lots of systems that write markers and values into it (@George I know you’d never do that, this is just for anyone visiting). If you’d like to use it yourself you should check out `Sitecore.Context.Database.Properties` for some interesting methods.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s