【发布时间】:2018-10-06 20:36:14
【问题描述】:
我在 .Net Standard 2.0 中开发了一个基于队列触发器的函数应用程序。 当应用程序因维护或新版本而停机时,队列中可能有超过 20000 条消息。 基本上,应用程序使用 XMLReader 读取每个 xml 文件的内容并创建一条记录。这些记录直接插入 Azure SQL 数据仓库。 但是当应用程序重新启动时,我们会遇到一些依赖错误,这都是由于 SQL 登录错误。
System.Data.SqlClient.SqlException (0x80131904): 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.
This failure occurred while attempting to connect to the routing destination.
The duration spent while attempting to connect to the original server was - [Pre-Login]
查看数据仓库的统计信息时,我可以看到当时有超过 800 个连接处于活动状态。所以我明白这可能太多了,但我怎么能解决这个问题,我认为没有办法限制同时功能应用程序的数量,...
如果有人有想法(即使是在周六晚上),请随意。
PS:在正常操作中,该功能工作正常,只是在重新启动时它会触发太多太快...
【问题讨论】:
-
你的连接字符串是什么样子的?
-
我只是在使用连接字符串构建器
connSql = EnergySql.CreateDBConnection(CommonCode.GetEnvironmentVariable("SQLDW_Datasource"), CommonCode.GetEnvironmentVariable("SQLDW_InitialCatalog"), CommonCode.GetEnvironmentVariable("SQLDW_User"), CommonCode.GetEnvironmentVariable("SQLDW_Password")); -
从这篇文章docs.microsoft.com/en-us/azure/sql-data-warehouse/…你可以配置连接字符串的超时时间。它说您应该将超时配置为 300 秒。你能试试这个吗?
标签: azure azure-functions azure-sqldw