我在运行一个长的Azure表存储查询6-7小时后5-6小时,Azure表存储抛出异常“无法从传输连接读取数据:一个现有连接被远程host.An强制关闭,现有连接被远程主机强制关闭”**
"Exception : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host., Stack Trace : at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext)
at Microsoft.WindowsAzure.Storage.Table.TableQuery`1.<>c__DisplayClass7.<ExecuteInternal>b__6(IContinuationToken continuationToken)
at Microsoft.WindowsAzure.Storage.Core.Util.CommonUtility.<LazyEnumerable>d__0`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)"
**不知道是什么引起了问题,谁能帮我找出这个错误的原因吗?
ServicePointManager.DefaultConnectionLimit = 48;
ServicePointManager.Expect100Continue = false;
ServicePointManager.UseNagleAlgorithm = false;我使用的是A7 (8 CPU内核,56 GB内存),即使配置很高,它也失败了。
还包括重试逻辑对表存储溢出执行查询,但没有运气。
var DefaultRequestOptions = new TableRequestOptions
{
RetryPolicy =new ExponentialRetry(TimeSpan.FromSeconds(3), 3),
//PayloadFormat = TablePayloadFormat.JsonNoMetadata
};
AzureTableQuery.Execute(DefaultRequestOptions).ToList();我还检查了Network :它显示有100 GB。网络带宽是否有任何限制。我请求任何人在这方面提供帮助。提前感谢
发布于 2015-01-06 22:21:13
对于一个需要这么长时间的查询,最好是以零碎的方式处理结果,而不是一次下载所有的内容。这样,如果查询在任何时候失败,就不必重新下载所有内容。例如:
TableContinuationToken token = null;
try
{
do
{
TableQuerySegment<ITableEntity> segment = AzureTableQuery.ExecuteSegmented(token);
// Do something with segment.Results(), which is this batch of results from the query
List<ITableEntity> results = segment.Results;
// Save the continuation token for the next iteration.
token = segment.ContinuationToken;
} while (token != null);
}
catch (Exception e)
{
// Handle exception, retry, etc
}这样,即使查询在半程内失败,也有部分结果,并且有延续令牌,因此可以从中断的地方继续查询,而不是从开始开始。
请注意,大多数表扫描都不是很有效;如果您的场景对延迟敏感,您可能需要重新设计表以允许更有效的查询。另外,我不知道你是如何在网络上得到100 GB/s的,但是它肯定不是全部来自这个查询,Azure存储不会为一个查询快速地推送数据。
https://stackoverflow.com/questions/27789360
复制相似问题