Update Stats Error - Msg 1222, Lock request time out period exceeded

Pds 46 Reputation points
2021-10-12T14:50:31.097+00:00

Hello,
I am running Weekly Index Optimizing job to Modify the stats but it's failing from last few times at this step - Modify Stats.
Actually we are running this off hours on Weekend using Ola's script.
Any one having issue or any suggestion?
Is it Ola's script having any work around?

We are getting following error message for some of the failed stats:

Msg 1222, Lock request time out period exceeded

Command: UPDATE STATISTICS [BIDS].[dbo].[WorkQ] [_WA_Sys_00000006_151B244E]
Msg 50000, Level 16, State 1, Server BIDSSql, Procedure CommandExecute, Line 167
Msg 1222, Lock request time out period exceeded.
Outcome: Failed
Duration: 01:00:00
DateTime: 2021-09-26 11:14:05

This is a Sql Server 2012 and Database is around 150 GB size.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,748 questions
{count} votes

16 answers

Sort by: Newest
  1. Pds 46 Reputation points
    2021-10-22T13:39:43.083+00:00

    Any idea if we can exclude the table from update stats?
    I am using Ola's script?

    Is it correct way to use?

    sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d DBAMaint -Q "EXECUTE [dbo].[IndexOptimize] @Databases = 'ALL_DATABASES', -TextDB.dbo.WQueuu, @FragmentationLow = NULL, @FragmentationMedium = NULL, @FragmentationHigh = NULL, @UpdateStatistics = 'ALL', @OnlyModifiedStatistics = 'Y', @TimeLimit = 3600, @LogToTable = 'Y'" -b


  2. Pds 46 Reputation points
    2021-10-17T19:21:00.69+00:00

    Thanks Erland.
    I think I should Exempt this table from update stats which will be better idea.


  3. Erland Sommarskog 101.2K Reputation points MVP
    2021-10-17T18:58:47.133+00:00

    Yes, sure, you can add a step to the reindex job that kills the spid, but as you described it, that process will soon be hammering the database again. So you would have to find away to stop this guy at the gate. You will need to discuss this with the vendor.

    Then again, what is most important? That the application process is doings it job, or that statistics are updated? Maybe the best is to exempt this table from the stats job, and rely solely on autostats? If this table is frequently updated, autostats should kick in often.

    Again, this is something you should discuss with the vendor

    0 comments No comments

  4. Pds 46 Reputation points
    2021-10-17T15:27:47.087+00:00

    Thanks once again Erland.
    I understood the @TimeLimit parameter, the reason I set it 3600 because job should not run mire then an hour.
    For @LockMessageSeverity to 10, not sure as job constantly running to update the table, looks like this table kind of keeping last entry - kind of log.
    Is it anyway I can add something which can Kill the blocking session when this jobs run?

    Thank You!

    0 comments No comments

  5. Erland Sommarskog 101.2K Reputation points MVP
    2021-10-16T17:40:42.527+00:00

    As I understand the @TimeLimit parameter, it controls how long time the job will run. If you set it to 3600, the job will stop after an hour. Or more precisely, it will not submit any new commands, but the command that is running when the hour expires will complete. Again, that is my interpretation.

    But you could try setting the parameter @LockMessageSeverity to 10. With this setting, the lock timeout will only produce an informational message but not stop the job.

    0 comments No comments