SqlException A severe error occurred on the current command. The results, if any, should be discarded

Vote:
 

Hi all, we have just upgrade to minor version as details below:

Old version:

        <PackageReference Include="EPiServer.Framework" Version="12.13.1" />
        <PackageReference Include="EPiServer.CMS.Core" Version="12.13.1" />
        <PackageReference Include="EPiServer.CMS.UI.Core" Version="12.17.1" />
        <PackageReference Include="EPiServer.Find.Cms" Version="14.2.4" />
        <PackageReference Include="EPiServer.CMS.AspNetCore.Routing" Version="12.13.1" />
        <PackageReference Include="EPiServer.CMS.AspNetCore.Templating" Version="12.13.1" />

New version:

<PackageReference Include="EPiServer.Framework" Version="12.19.0" />
<PackageReference Include="EPiServer.CMS.Core" Version="12.19.0" />
<PackageReference Include="EPiServer.CMS.UI.Core" Version="12.23.0" />
<PackageReference Include="EPiServer.Find.Cms" Version="14.2.4" />
<PackageReference Include="EPiServer.CMS.AspNetCore.Routing" Version="12.19.0" />
<PackageReference Include="EPiServer.CMS.AspNetCore.Templating" Version="12.19.0" />

After upgrading, we are facing a lot of exception regarding SQL, those exceptions were raised by both builtin schedule job (Search and Navigation indexing) and custom schedule jobs:

An exception occurred during reindex operation. System.AggregateException: One or more errors occurred. (A severe error occurred on the current command.  The results, if any, should be discarded.)
 ---> Microsoft.Data.SqlClient.SqlException (0x80131904): A severe error occurred on the current command.  The results, if any, should be discarded.
   at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at Microsoft.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at Microsoft.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[] buffer, TransactionManagerRequestType request, String transactionName, TransactionManagerIsolationLevel isoLevel, Int32 timeout, SqlInternalTransaction transaction, TdsParserStateObject stateObj, Boolean isDelegateControlRequest)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransaction2005(TransactionRequest transactionRequest, String transactionName, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest)
   at Microsoft.Data.SqlClient.SqlInternalConnection.BeginSqlTransaction(IsolationLevel iso, String transactionName, Boolean shouldReconnect)
   at Microsoft.Data.SqlClient.SqlConnection.BeginTransaction(IsolationLevel iso, String transactionName)
   at Microsoft.Data.SqlClient.SqlConnection.BeginDbTransaction(IsolationLevel isolationLevel)
   at EPiServer.Data.Providers.Internal.ConnectionContext.BeginTransaction()
   at EPiServer.Data.Internal.MARSConnectionContextHandler.CreateConnectionScope(Boolean requireTransaction, Action completeAction)
   at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass28_0`1.<ExecuteTransaction>b__0()
   at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method)
   at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.ExecuteTransaction(Action action)
   at EPiServer.Scheduler.Internal.DefaultScheduledJobExecutor.JobInstance_StatusChanged(Object sender, JobStatusChangedEventArgs e)
   at EPiServer.Find.Cms.IndexingJobService.<>c__DisplayClass8_1.<Start>b__0(ReIndexStatus status)
   at EPiServer.Find.Cms.ContentIndexer.<>c__DisplayClass52_3.<ReIndex>b__1()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
ClientConnectionId:9de73803-cc56-4d49-b309-902320a7f59f
ClientConnectionId before routing:ef6bcfe2-7e38-4278-8ef2-82bda57159a9
Routing Destination:a39b667c7702.tr31968.westeurope1-a.worker.database.windows.net,11010
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.WaitAllCore(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at EPiServer.Find.Cms.ContentIndexer.ReIndex(SiteDefinition siteDefinition, Action`1 statusAction, Func`1 isStopped, Nullable`1 startTime)

And we are also facing the issue on the async/awai or multiple threads code that use ContentLoader API :

 EPiServer.Framework.Cache.ObjectInstanceCacheExtensions[0]
      Failed to Read cacheKey = 'EPContentVersion:1616316_54892138'
      System.InvalidOperationException: ExecuteReader requires the command to have a transaction when the connection assigned to the command is in a pending local transaction.  The Transaction property of the command has not been initialized.
         at Microsoft.Data.SqlClient.SqlCommand.ValidateCommand(Boolean isAsync, String method)
         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.ContentLoadDB.<>c__DisplayClass4_0.<LoadVersion>b__0()
         at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass26_0`1.<Execute>b__0()
         at EPiServer.DataAccess.Internal.ContentLoadDB.LoadVersion(ContentReference contentLink, Int32 languageBranchID)
         at EPiServer.Core.ContentProvider.<>c__DisplayClass123_0.<LoadContentFromCacheOrRepository>b__0()
         at EPiServer.Framework.Cache.ObjectInstanceCacheExtensions.ReadThroughWithWait[T](IObjectInstanceCache ca

Do you have any idea?

#314342
Dec 18, 2023 3:09
* 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.