3

我有一个存储过程不断失败,并在特定用户上显示错误消息“超时已过期”。

所有其他用户都能够很好地调用 sp,甚至我也能够使用查询分析器正常调用 sp——它只需 10 秒即可完成。但是对于有问题的用户,日志显示 ASP 总是挂起大约 5 分钟,然后超时中止。

我像这样从 ASP 页面调用“ EXEC SP_TV_GET_CLOSED_BANKS_BY_USERS '006111'

有人知道如何诊断问题吗?我已经尝试查看数据库中的死锁,但没有找到任何死锁。

谢谢,

4

5 回答 5

5

一些想法...

阅读评论表明参数嗅探导致了问题。

  • 对于其他用户,缓存的计划足以满足他们发送的参数
  • 对于这个用户,缓存的计划可能是错误的

如果此用户的行数远多于其他用户,或者在另一个表中有行(因此不同的表/索引查找/扫描会更好),则可能会发生这种情况

测试参数嗅探:

  • 在调用或 def 中使用 RECOMPILE(临时)。对于复杂的查询,这可能会很慢
  • 超时后重建索引(或只是统计信息)并重试。这会使所有缓存的计划无效

修复:屏蔽参数

DECLARE @MaskedParam varchar(10)
SELECT @MaskedParam = @SignaureParam

SELECT...WHERE column = @MaskedParam

只需谷歌“参数嗅探”和“参数屏蔽”

于 2008-11-09T08:13:13.753 回答
0

我想要回答你的问题,我们可能需要更多信息。

例如,您是否使用 Active Directory 来验证您的用户?您是否使用过 SQL 探查器进行调查?听起来这可能是一个身份验证问题,SQL Server 在验证此特定用户时遇到问题。

于 2008-11-07T18:51:33.997 回答
0

对我来说听起来像一个死锁问题..

还要确保此用户在 SQL Server 中具有执行权限和读取权限

但是,如果当时正在写入信息,因为它试图被读取,您将死锁,因为事务尚未提交。

Jeff 写了一篇很棒的文章,讲述了他在这方面和 stackoverflow 方面的经验。 http://www.codinghorror.com/blog/archives/001166.html

于 2008-11-07T18:57:18.290 回答
0

Couple of things to check:

  1. Does this happen only on that specific user's machine? Can he try it from another machine? - it might be a client configuration problem.
  2. Can you capture the actual string that this specific user runs and run it from an ASP page? It might be that user executes the SP in a way that generates either a loop or a massive load of data.
  3. Finally, if you're using an intra-organization application, it might be that your particular user's permissions are different than the others. You can compare them at the Active Directory level.

Now, I can recommend a commercial software that will definitely solve your issue. It records end-to-end transactions, and analyzes particular failures. But I do not want to advertise in this forum. If you'd like, drop me a note and I'll explain more.

于 2008-11-08T04:15:02.097 回答
0

好吧,我建议您使用 SQL Server Profiler 并打开一个新会话。从您的 ASP 页调用您的存储过程,看看发生了什么。虽然这可能无法解决您的问题,但它肯定可以为您提供一个起点,让您自己进行一些“调查”。

于 2008-11-08T12:41:46.597 回答