简单查询时出现 ODBC 超时错误
针对 SQL Server 数据库执行 SQL 代码时,我们遇到以下 ODBC 超时错误。
“连接错误:[Microsoft][ODBC SQL Server 驱动程序]超时已过期” “S1T00”
这里令人困惑的是,我们的堆栈转储表明发生超时时正在执行的 SQL 代码非常简单:
SELECT @@TRANCOUNT AS TranCount
或有时...
BEGIN TRANSACTION
我们的客户端说,数据库服务器在发生这些错误时,并不是压倒性的。什么可能导致这些简单的语句超时?我相信超时设置相当短(1 到 5 秒之间)...但是,SELECT @@TRANCOUNT 应该是瞬时的。
有什么想法吗?
We are getting the following ODBC timeout errors when executing sql code against a SQL Server database.
"Connectivity error: [Microsoft][ODBC SQL Server Driver]Timeout expired"
"S1T00"
The confusing thing here is that our stack dump says that the SQL code it is executing when the timeout occurrs - is very simple:
SELECT @@TRANCOUNT AS TranCount
or sometimes...
BEGIN TRANSACTION
Our client says that the load on the database server at the time that these errors occur, is not overwhelming. What could possibly cause those simple statements to timeout? I believe the timeout setting is fairly short (between 1 and 5 seconds)... but still, SELECT @@TRANCOUNT should be instantaneous.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它可能与驱动程序相关,但我认为 ODBC 超时可能由客户端处理。这意味着,任何网络延迟,甚至是由病毒扫描程序到其他进程等任何原因引起的轻微服务器中断,都可能很容易导致 1 或 2 秒的延迟。因此,如果您的超时实际上是 1 秒,那么出现超时错误似乎并不奇怪。
对于合理的超时时间来说,即使是 5 秒似乎也有点偏低。这是假设客户端和服务器不在同一台物理机器上。
It may be driver-dependent, but I think the ODBC timeout may be handled by the client. This means that any network delays or even slight server hiccups caused by anything from a virus scanner to miscellaneous processes could easily cause a 1 or 2 second delay. So if your timeout is actually 1 second, it doesn't seem surprising that you might get timeout errors.
It seems that even 5 seconds is a bit on the low side for a reasonable timeout. This is assuming that the client and server are not on the same physical machine.