November Happy Hour will be moved to Thursday December 5th.

Search & Navigation Content Indexing Job fails both on DXP and locally

Vote:
 

I'm getting this error recently when trying to do a re-index of a site. The re-index job will run for 15 seconds then just stop.

EPiServer.Find.Cms.ContentIndexer: Error: 148-JCRXXY2 An exception occurred while fetching content. Invalid operation. The connection is closed..
System.InvalidOperationException: Invalid operation. The connection is closed.
   at Microsoft.Data.ProviderBase.DbConnectionClosed.CreateReferenceCollection()
   at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
   at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method)
   at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at EPiServer.DataAccess.Internal.ContentListDB.ReadPublishedList(DbCommand cmd)
   at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass26_0`1.<Execute>b__0()
   at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method)
   at EPiServer.DataAccess.Internal.ContentListDB.LoadSpecificContentInstances(IList`1 contentLinks, Int32 languageBranchID)
   at EPiServer.Core.Internal.DefaultContentProvider.BatchLoad(IList`1 contentLinks, Func`2 dbLoader)
   at EPiServer.Core.Internal.DefaultContentProvider.LoadContents(IList`1 contentReferences, ILanguageSelector selector)
   at EPiServer.Core.ContentProvider.GetContentBatch(IList`1 batch, ILanguageSelector selector, List`1& contents, Dictionary`2& contentMap)
   at EPiServer.Core.ContentProvider.GetScatteredContents(IEnumerable`1 contentLinks, ILanguageSelector selector)
   at EPiServer.Core.Internal.ProviderPipelineImplementation.GetItems(ContentProvider provider, IList`1 contentLinks, LoaderOptions loaderOptions)
   at EPiServer.Core.Internal.DefaultContentLoader.GetItems(IEnumerable`1 contentLinks, LoaderOptions loaderOptions)
   at EPiServer.Find.Cms.ContentIndexer.<>c__DisplayClass52_3.<ReIndex>b__1()

On DXP I also get this kind of error with the same result that not all items are indexed

System.InvalidOperationException: Cannot create a command without an existing connection, you can use DbFactory to create stand-alone command objects
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.CreateCommand()
at EPiServer.DataAccess.Internal.ContentListDB.<>c__DisplayClass18_0.<LoadChildrenReferencesAndTypes>b__0()
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass26_0`1.<Execute>b__0()
at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method)
at EPiServer.DataAccess.Internal.ContentListDB.LoadChildrenReferencesAndTypes(Int32 pageId, String languageID, FilterSortOrder& parentSortOrder)
at EPiServer.Core.Internal.DefaultContentProvider.LoadChildrenReferencesAndTypes(ContentReference contentLink, String languageID, Boolean& languageSpecific)
at EPiServer.Core.ContentProvider.<>c__DisplayClass114_0`1.<TryGetChildren>b__0()
at EPiServer.Framework.Cache.ObjectInstanceCacheExtensions.ReadThroughWithWait[T](IObjectInstanceCache cache, String cacheKey, Func`1 readValue, Func`2 evictionPolicy)

Weird part is that if I try to index the site via code everything works as expected which tells me that there's maybe something wrong in Epis internal classes? I Tried this snippet just to see if something crashed and it ran without a problem.

var contentItems = _contentLoader.GetDescendents(ContentReference.StartPage).Select(x => _contentLoader.Get<IContent>(x)).ToList();
foreach (var contentItem in contentItems)
{
    SearchClient.Instance.Index(contentItem);
}
#306820
Edited, Aug 15, 2023 14:38
Joonas M. Partanen - Aug 23, 2023 12:39
Did you find any solution to this, Alexander?

I'm facing the same issue starting from EPiServer.CMS 12.22.2. With 12.22.1, the indexing job seems to work just fine.
Alexander Wagner - Aug 23, 2023 12:51
I'm afraid not. But I've opened a ticket with Optimizely support so they can look at the problem. I'll get back to you once I've got any answers.
Vote:
 

Thank you all for reporting this issue and your findings. We are working on a fix for this.

#307402
Edited, Aug 24, 2023 7:36
Vote:
 

This will be fixed with next CMS and Find package

CMS-29569 BackgroundContext should be isolated
https://world.optimizely.com/support/bug-list/bug/CMS-29569

FIND-11746 Background tasks should run in own context
(Bug not made public yet)

#307579
Aug 28, 2023 15:58
Vote:
 

Great, Thank you for the update Daniel!

#307619
Aug 29, 2023 6:20
Vote:
 

Just tried it out and it works like a charm now!

#307750
Aug 31, 2023 12:58
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.