Getting a System.Threading.ThreadAbortException when trying to generate a sitemap for a product catalog

John McKillip
Member since: 2015
 

Hi,

I am stuck on this currently. Here is the stack trace. It is happening when GetDescendants is called on the root reference to my catalog:

2018-05-24 14:58:40,480 [12] ERROR EPiServer.Framework.Cache.ObjectInstanceCacheExtensions: Failed to Read cacheKey = 'EPPageData:1073764959:en__CatalogContent'
System.Exception: Exception in ecf_CatalogNode:  ---> System.Threading.ThreadAbortException: Thread was being aborted.
   at SNIReadSyncOverAsync(SNI_ConnWrapper* , SNI_Packet** , Int32 )
   at SNINativeMethodWrapper.SNIReadSyncOverAsync(SafeHandle pConn, IntPtr& packet, Int32 timeout)
   at System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync()
   at System.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket()
   at System.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer()
   at System.Data.SqlClient.TdsParserStateObject.TryReadByte(Byte& value)
   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)
   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 Mediachase.Data.Provider.SqlDataProvider.<>c__DisplayClass17_1.b__0()
   at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method)
   at Mediachase.Data.Provider.SqlDataProvider.LoadDataSet(DataCommand command)
   --- End of inner exception stack trace ---
   at Mediachase.Data.Provider.SqlDataProvider.LoadDataSet(DataCommand command)
   at Mediachase.Commerce.Catalog.Data.CatalogNodeAdmin.Load(Int32 catalogNodeId)
   at Mediachase.Commerce.Catalog.Managers.CatalogNodeManager.<>c__DisplayClass37_0.b__0()
   at Mediachase.Data.Provider.Internal.Extensions.ObjectInstanceCacheExtensions.ReadThrough[T](IObjectInstanceCache cache, ReadMode readMode, String cacheKey, Func`1 load, Func`2 evictionPolicy)
   at Mediachase.Data.Provider.Internal.Extensions.ObjectInstanceCacheExtensions.ReadThrough[T](IObjectInstanceCache cache, ReadMode readMode, String cacheKey, Func`1 load, IEnumerable`1 masterKeys, TimeSpan duration)
   at Mediachase.Commerce.Catalog.CatalogCache.ReadThrough[T](ReadMode readMode, String key, IEnumerable`1 masterKeys, TimeSpan timeout, Func`1 load)
   at Mediachase.Commerce.Catalog.Managers.CatalogNodeManager.ExecuteDtoThroughCache(ReadMode readMode, String cacheKey, IEnumerable`1 masterKeys, CatalogNodeResponseGroup responseGroup, Action`1 adminAction)
   at Mediachase.Commerce.Catalog.Managers.CatalogNodeManager.GetCatalogNodeDto(Int32 catalogNodeId, CatalogNodeResponseGroup responseGroup, ReadMode readMode)
   at EPiServer.Commerce.Catalog.Provider.Construction.NodeBuilder.Create(IList`1 contentLinks, String language)
   at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.ConstructContent(IList`1 contentLinks, Func`3 createContentFunc)
   at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.LoadSpecificContentInstances(IList`1 contentLinks, String language)
   at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.BatchLoad(IList`1 contentLinks, Func`2 dbLoader)
   at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContents(IList`1 contentReferences, ILanguageSelector selector)
   at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
   at EPiServer.Core.ContentProvider.<>c__DisplayClass121_0.b__0()
   at EPiServer.Framework.Cache.ObjectInstanceCacheExtensions.ReadThroughWithWait[T](IObjectInstanceCache cache, String cacheKey, Func`1 readValue, Func`2 evictionPolicy)

The catalog is decently large at 40k products. I recently upgraded to latest versions of Episerver and started having this issue. We have a custom package for generating the sitemaps. I have also tried using the Geta Seo.Commerce.Sitemaps and I am not seeing that error, but, the job just runs forever and never generates anything. Here are the versions my app is running:

 
  
  
  
  
  
  
  
  
  

Any help would be greatly appreciated!


-John



#193764 Jun 04, 2018 23:23
  • Magnus Rahl
    Member since: 2008
     

    While I don't know the source of this problem or the reason why it seems to be related to the upgrade, the mention of GetDescendents and large structures always makes me a bit worried. Make sure you use the references returned wisely, i.e. load batches of content items and process them, then drop the reference to those items. If you hold reference to huge amount of content at once, e.g. by loading all the content the references from GetDescendents point to into a list, you could run out of memory.

    #193772 Jun 05, 2018 8:14
  • Magnus Rahl
    Member since: 2008
     

    Is the code running as part of a web request? If so, it looks like the request timeout is hit, so the framework is aborting the request thread. 

    #193773 Jun 05, 2018 8:18
  • Quan Mai
    Member since: 2011
     

    In addition to what Rahl said, can you use SQL Profiler to see which parameters were being called, and run the stored procedure directly against your DB in SQL Server Management Studio to see how long in take ?

    #193775 Jun 05, 2018 8:51
  • John McKillip
    Member since: 2015
     

    Hi! Thanks for the responses. Sorry it took me so long to respond. It was definitely calling GetDescendents on the catalog root that was causing the issue. I ended up using Vulcan (elastic search scroll api) to build out the sitemap instead of the IContentLoader. Things are looking good now.

    #195916 Aug 11, 2018 15:45