运行ToList时出现内部连接致命错误

问题描述 投票:0回答:1

在我的业务中,我从 DataFactory 并行调用多个 Azure 函数。 如果此时尝试执行 ToList,则 Close() 过程中会发生错误,如下所示。

System.InvalidOperationException: Internal connection fatal error.
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at Microsoft.Data.SqlClient.SqlDataReader.TryCloseInternal(Boolean closeReader)
at Microsoft.Data.SqlClient.SqlDataReader.Close()
at Microsoft.EntityFrameworkCore.Storage.RelationalDataReader.Close()
at Microsoft.EntityFrameworkCore.Storage.RelationalDataReader.Dispose()
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.Enumerator.Dispose() 
at System.Collections.Generic.List1..ctor(IEnumerable1 collection) 
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
at ProcessAndCheck.Activities.CreateTReturnNewSerious.RunActivity(TaskOrchestrationContext context, FunctionContext functionContext) 
in C:\Users\yamaguchi.chieko\Desktop\Next-Generation Quality Management\analysis-source\ProcessAndCheck\Activities\CreateTReturnNewSerious.cs:line 73

我想大概是从1到3的流程。 如果有人知道请告诉我。

  1. 另一个 Azure 函数开始查询数据库
  2. 1未完成时执行ToList(执行对DB的查询)
  3. 其他进程未关闭导致内部连接致命错误

另外,在这种情况下,我正在考虑使用异步处理(ToListAsync)作为对策。 你认为会有效果吗? 请问有什么有效的方法吗

sql-server azure azure-data-factory
1个回答
0
投票

任何异步方法(例如 ToListAsync)都应该解决该错误,它们确保安全释放连接

© www.soinside.com 2019 - 2024. All rights reserved.