简体   繁体   English

SQL Azure - 登录后阶段超时

[英]SQL Azure - The timeout period elapsed during the post-login phase

I have azure cloud service - 2 web instances, serving about 500,000 requests per day.我有 azure 云服务 - 2 web 个实例,每天处理大约 500,000 个请求。 Using Azure business database.使用Azure业务数据库。 There is one issue with it - sometimes (avg. once per day, but not in the same time) there is 2-3 minutes long interval while i am unable to query DB, the error message is like this:它有一个问题 - 有时(平均每天一次,但不是在同一时间)有 2-3 分钟长的间隔,而我无法查询数据库,错误消息是这样的:

System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.Data.SqlClient.SqlException: Connection Timeout Expired.  The timeout period elapsed during the post-login phase.  The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while attempting to create multiple active connections.  The duration spent while attempting to connect to this server was - [Pre-Login] initialization=1; handshake=12; [Login] initialization=0; authentication=0; [Post-Login] complete=14004;  ---> System.ComponentModel.Win32Exception: The wait operation timed out
   --- End of inner exception stack trace ---
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at System.Data.Entity.Infrastructure.DbExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
   at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
   --- End of inner exception stack trace ---
   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
   at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection()
   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__DisplayClassb.<GetResults>b__9()
   at System.Data.Entity.Infrastructure.DbExecutionStrategy.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.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at MyProject.MyRepository.GetItems(Boolean includePremium, Int32 a, Int32 b, Int32 c)
   at MyProject.Controllers.MyController.GetItems(String Id, String device)

Numbers in the message - [Pre-Login] initialization=1;消息中的数字 - [Pre-Login] initialization=1; handshake=12;握手=12; [Login] initialization=0; [登录]初始化=0; authentication=0;认证=0; [Post-Login] complete=14004 - are always the same, not some random wait times or something... [登录后] complete=14004 - 总是一样的,不是随机等待时间之类的……

Of course I tried to google this error, but all I could find was related to wrong connection management with plain ADO.NET etc. I am using Entity Framework 6, with code-first model, linq to entities queries, queries are not heavy (few ms, always under 1s).当然我试着用谷歌搜索这个错误,但我能找到的只是与错误的连接管理有关,普通的 ADO.NET 等。我正在使用实体框架 6,代码优先 model,linq 到实体查询,查询不重(几毫秒, 总是小于 1s)。

There is this question on SO: Connection timeout in SQL Azure with answer like "this is transient error, just try again" - but this wont solve it for me, I got hundreds of these errors within this interval, I am pretty sure every request fail, so "wait 5 sec and try again" policy wont help here. SO 上有这样一个问题: SQL Azure 中的连接超时,回答如“这是暂时性错误,请重试” - 但这不会为我解决问题,我在此间隔内遇到了数百个这样的错误,我很确定每个请求失败,所以“等待 5 秒再试”政策在这里无济于事。

Is there something special about Azure DB which I must do about connection lifetime management in EF?关于 Azure DB,我必须对 EF 中的连接生命周期管理做一些特别的事情吗? Or you think this can be error message for "throttling" DB?或者您认为这可能是“节流”数据库的错误消息?

Well, after some time and some refactoring, it seems this error is indeed indicating throttling. 好吧,经过一段时间的重构之后,看来这个错误确实表明了节流。 We managed to reduce number of requests per minute, and without any other changes these errors disappeared entirely. 我们设法减少了每分钟的请求数量,并且没有进行任何其他更改,这些错误就完全消失了。

Its a shame that SQL Azure dont give more helpful messages about limits/resources. 令人遗憾的是,SQL Azure没有提供有关限制/资源的更多有用信息。

I was able to fix this issue by disabling the Auto-Pause option.我能够通过禁用自动暂停选项来解决这个问题。 In my case, Auto pause option was enabled with 1 hour as its value and so the database was paused after 1 hour of idle time.在我的例子中,自动暂停选项启用了 1 小时作为其值,因此数据库在空闲时间 1 小时后暂停。 So either you can increase this Auto Pause value or can disable it completely.因此,您可以增加此自动暂停值或完全禁用它。

CAUTION: This will impact your monthly charges注意:这会影响您的每月费用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 EF、SQL Server - 连接超时已过期。 登录后阶段已过的超时时间 - EF, SQL Server - Connection Timeout Expired. The timeout period elapsed during the post-login phase 连接超时已过期。 登录后阶段已过的超时时间 - Connection Timeout Expired. The timeout period elapsed during the post-login phase 登录后阶段连接 SQL Server 超时 - Timeout connecting SQL Server during the post-login phase SQL Azure 上的服务器:“执行超时已过期。操作完成前超时时间已过,或者服务器没有响应。” - SQL Server on Azure: "Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding." 超时已过。 在 Azure sql 上的操作完成之前超时时间已过 - Timeout expired. The timeout period elapsed prior to completion of the operation on Azure sql SQL Server 2014年之前超时时间已过去 - Timeout period elapsed prior in SQL Server 2014 始终使用SQL Azure从会话状态提供程序(实体框架)接收“超时期限” - Consistently receiving “timeout period elapsed” from session state provider (Entity Framework) with SQL Azure 超时到期超时时间已过去SQL Server 2012 - Timeout expired the timeout period elapsed SQL Server 2012 连接超时已过期。 尝试使用登录前握手确认时经过的超时时间 - connection timeout expired. the timeout period elapsed while attempting to consume the pre-login handshake acknowledgement SQl服务器我需要修复“超时已过期”错误。 超时时间已过” - SQl Server I need to fix the error of “Timeout expired. The timeout period elapsed”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM