Episerver CMS - Timeout exceptions during scheduled jobs

  • Updated
Description

Are you seeing SQL timeout exceptions during scheduled jobs like the Remove Unrelated Content Assets
jobs and it's not getting better after optimizing database or cleaning up junk?

020-01-23T17:01:00,Error,anti01mstr86tjpprod,b1962a,637153956605841977,0,26208,67,"EPiServer.DataAbstraction.ScheduledJob : Job EPiServer.Util.CleanUnusedAssetsFoldersJob failed for the job 'Remove Unrelated Content Assets' with jobId ='e5351acb-e42f-4093-b26e-dc7cd89028c8' 
System.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
  at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
  at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
  at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
  at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
  at System.Data.SqlClient.SqlDataReader.get_MetaData()
  at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
  at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
  at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
  at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
  at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
  at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
  at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
  at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
  at EPiServer.DataAccess.Internal.ContentSaveDB.<>c__DisplayClass17_0.<GetReferenceInformationForContent>b__0()
  at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass31_0`1.<Execute>b__0()
  at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method)
  at EPiServer.DataAccess.Internal.ContentSaveDB.GetReferenceInformationForContent(ContentReference contentLink, Boolean includeDecendents)
  at EPiServer.Core.Internal.DefaultContentProvider.GetReferencesToLocalContent(ContentReference contentLink, Boolean includeDecendents)
  at EPiServer.Core.Internal.DefaultContentRepository.GetReferencesToContent(ContentReference contentLink, IEnumerable`1 descendents, Boolean includeDescendants)
  at EPiServer.Core.Internal.DefaultContentRepository.Delete(ContentReference contentLink, Boolean forceDelete, AccessLevel access)
  at EPiServer.Util.CleanUnusedAssetsFoldersJob.Execute()
  at EPiServer.Scheduler.Internal.DefaultScheduledJobExecutor.<Execute>d__31.MoveNext()
Steps

Try increasing the timeout by adding the following to your web.config. Here a example of setting the databaseQueryTimeout to 15 minutes and number of retries to 5.

1. Add this into <configuration> <configSections>

2. If you're on CMS 11 add

<section name="episerver.dataStore" type="EPiServer.Data.Configuration.EPiServerDataStoreSection, EPiServer.Framework.AspNet" />

 if your on an older version add

<section name="episerver.dataStore" type="EPiServer.Data.Configuration.EPiServerDataStoreSection, EPiServer.Data" />

3. And then add the below into <configuration>

 <episerver.dataStore>
<dataSettings
connectionStringName="EPiServerDB"
retries="5"
retryDelay="0:0:0.1"
databaseQueryTimeout="0:15:00" />
</episerver.dataStore>

 

For the 'Maintain database' scheduled job there is a specific timeout app setting called DataBaseIndicesJobCommandTimeOut

By default, the job times out after 30 seconds. If the job does not finish within that time, an exception is generated.

Add a setting to the web.config’s appSettings section using the key episerver::DataBaseIndicesJobCommandTimeOut.

Within this new appsetting setting, set the value to the maximum number of seconds for which you want the job to run.