Start a new topic

Error while indexing 3 millions products in elastic

Hello.


We are trying to index 3 millons products in elastic, eventually the indexing fails with:

System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> System.Data.SqlClient.SqlException: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception: The wait operation timed out

 --- End of inner exception stack trace ---

 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)

 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.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)

 at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)

 at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)

 --- End of inner exception stack trace ---

 at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)

 at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)

 at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)

 at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()

 at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)

 at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)

 at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()

 at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()

 at System.Linq.Buffer`1..ctor(IEnumerable`1 source)

 at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)

 at VirtoCommerce.CatalogModule.Data.Services.CatalogSearchServiceImpl.SearchItems(SearchCriteria criteria, SearchResult result)

 at VirtoCommerce.CatalogModule.Data.Services.CatalogSearchServiceImpl.<>c__DisplayClass7_0.<Search>b__0()

 at System.Threading.Tasks.Task.Execute()

 --- End of inner exception stack trace ---

 at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)

 at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout)

 at System.Threading.Tasks.Task.WaitAll(Task[] tasks)

 at VirtoCommerce.CatalogModule.Data.Services.CatalogSearchServiceImpl.Search(SearchCriteria criteria)

 at VirtoCommerce.SearchApiModule.Data.Services.CatalogSearchServiceDecorator.Search(SearchCriteria criteria)

 at VirtoCommerce.SearchApiModule.Data.Services.CatalogItemIndexBuilder.<>c__DisplayClass25_0.<GetPartitionsForAllProducts>b__0(Int32 index)

 at System.Threading.Tasks.Parallel.<>c__DisplayClass17_0`1.<ForWorker>b__1()

 at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)

 at System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object )

 --- End of inner exception stack trace ---

 at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)

 at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)

 at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)

 at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body)

 at VirtoCommerce.SearchApiModule.Data.Services.CatalogItemIndexBuilder.GetPartitionsForAllProducts()

 at VirtoCommerce.SearchApiModule.Data.Services.CatalogItemIndexBuilder.GetPartitions(Boolean rebuild, DateTime startDate, DateTime endDate)

 at VirtoCommerce.SearchModule.Data.Services.SearchIndexController.BuildIndex(String scope, String documentType, Action`1 progressCallback, String[] documentsIds)

 ---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> System.Data.SqlClient.SqlException: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception: The wait operation timed out

 --- End of inner exception stack trace ---

 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)

 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..

-


We import the products via a csv import and then press the "rebuild index" button.

Any ideas? How can we increase the command timeout?


Best regards / Johan

1 Comment

This can be done when the catalog repository is being constructed: in the constructor itself or in the Module.Initialize() method.


constructor:

public CatalogRepositoryImpl(string nameOrConnectionString, params IInterceptor[] interceptors)
    : base(nameOrConnectionString, null, interceptors)
{
    Database.SetInitializer<CatalogRepositoryImpl>(null);
    Database.CommandTimeout = 180; // 180 seconds
} 


or Module.Initialize():

Func<ICatalogRepository> catalogRepFactory = () =>
{
    var repository = new CatalogRepositoryImpl(_connectionStringName, new EntityPrimaryKeyGeneratorInterceptor(), _container.Resolve<AuditableInterceptor>(),
        new ChangeLogInterceptor(_container.Resolve<Func<IPlatformRepository>>(), ChangeLogPolicy.Cumulative, new[] { typeof(Item).Name }, _container.Resolve<IUserNameResolver>()));
    repository.Database.CommandTimeout = 180; // 180 seconds
    return repository;
};
_container.RegisterInstance(catalogRepFactory);


Login or Signup to post a comment