Stored Procedure failing on a specific user

你离开我真会死。 提交于 2019-11-29 15:48:54
gbn

Some thoughts...

Reading the comments suggests that parameter sniffing is causing the issue.

  • For the other users, the cached plan is good enough for the parameter that they send
  • For this user, the cached plan is probably wrong

This could happen if this user has far more rows than other users, or has rows in another table (so a different table/index seek/scan would be better)

To test for parameter sniffing:

  • use RECOMPILE (temporarily) on the call or in the def. This could be slow for complex query
  • Rebuild the indexes (or just statistics) after the timeout and try again. This invalidates all cached plans

To fix: Mask the parameter

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

SELECT...WHERE column = @MaskedParam

Just google "Parameter sniffing" and "Parameter masking"

I think to answer your question, we may need a bit more information.

For example, are you using Active directory to authenticate your users? Have you used the SQL profiler to investigate? It sounds like it could be an auth issue where SQL Server is having problems authenticating this particular user.

Sounds to me like a dead lock issue..

Also make sure this user has execute rights and read rights in SQL Server

But if at the time info is being written as its trying to be read you will dead lock, as the transaction has not yet been committed.

Jeff did a great post about his experience with that and stackoverflow. http://www.codinghorror.com/blog/archives/001166.html

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.

Well, I could suggest that you use SQL Server Profiler and open a new session. Invoke your stored procedure from your ASP page and see what is happening. While this may not solve your problem, it can surely provide a starting point for you to carry out some 'investigation' of your own.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!