Epinova / Epinova.Elasticsearch

A search-plugin for Episerver CMS and Commerce
MIT License
29 stars 20 forks source link

Error on stats tab #213

Open scrog opened 7 months ago

scrog commented 7 months ago

Hi, We have a customer who have an issue with the production environment, when trying to access the stats tab there is an error: [ArgumentException: An item with the same key has already been added.] System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +60 System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) +5790801 System.Linq.Enumerable.ToDictionary(IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) +302 Epinova.ElasticSearch.Core.EPiServer.Controllers.ElasticTrackingController.GetModel() in C:\projects\epinova-elasticsearch\src\Epinova.ElasticSearch.Core.EPiServer\Controllers\ElasticTrackingController.cs:45 Epinova.ElasticSearch.Core.EPiServer.Controllers.ElasticTrackingController.Index() in C:\projects\epinova-elasticsearch\src\Epinova.ElasticSearch.Core.EPiServer\Controllers\ElasticTrackingController.cs:33 lambda_method(Closure , ControllerBase , Object[] ) +87 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +35 System.Web.Mvc.Async.<>c.<BeginInvokeSynchronousActionMethod>b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +39 System.Web.Mvc.Async.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) +77 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.AsyncInvocationWithFilters.b11_0() +72 System.Web.Mvc.Async.<>c__DisplayClass11_1.b2() +396 System.Web.Mvc.Async.<>cDisplayClass11_1.b2() +396 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.<>cDisplayClass3_6.b3() +50 System.Web.Mvc.Async.<>cDisplayClass3_1.b5(IAsyncResult asyncResult) +188 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38 System.Web.Mvc.<>c.b152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +29 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +73 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +39 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38 System.Web.Mvc.<>c.b20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +43 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +73 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +651 System.Web.<>c__DisplayClass285_0.<ExecuteStepImpl>b__0() +40 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +155 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +134

Any ideas?

Regards!

scrog commented 7 months ago

Hi, No one who has any input on this?

Regards!

otanum commented 7 months ago

Please validate that tracking table has the correct primary keys set. A similar error was fixed in https://github.com/Epinova/Epinova.Elasticsearch/commit/80f55d084d95e2492791ddd351f41f288d8ea1b9

The fix primary keys call will most likely fail if errors already exist in the table.

scrog commented 7 months ago

Thanks! What can be done if error in primary keys are found?

Regards!

otanum commented 7 months ago

The easiest solution is to empty the table.

If the search stats are really important you have to write query to locate the problems.

scrog commented 7 months ago

Thanks, will look into it. Maybe will return with more questions :-)

scrog commented 7 months ago

@otanum You where spot on, it was a duplicate in the tracking table, it was enough to remove that and everything started working again.

Thanks for your help!