死锁 - 重试交易 [英] deadlock - retrying the transaction

查看:104
本文介绍了死锁 - 重试交易的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我的C#网络应用程序越大,我需要在

繁琐的重试代码块中放置的地方越多确定可以碰到的数据运行数据库死锁重新运行(重试)3-4次,如果在那之后放弃它,那么它仍然处于死锁状态。我很确定很多有经验的人已经在某处以某种方式解决了这个问题。有替代品吗?

感谢您的意见和建议。

解决方案

大多数死锁都是由于索引不良以及表格的

顺序更新不一致。您可能希望更多地关注数据库

架构和代码与C#代码。


-

Andrew J凯莉SQL MVP

Zeng <泽****** @ hotmail.com>在留言中写道

新闻:%2 **************** @ TK2MSFTNGP14.phx.gbl ...



我的C#Web应用程序越大,我需要放置更多的地方
繁琐的重试代码块,以确保可以运行的操作
数据库死锁重新运行(重试)3-4次,如果
之后仍然处于死锁状态,则放弃。我很确定很多有经验的人已经在某处以某种方式解决了这个问题。有替代品吗?
感谢您的意见和建议。



感谢您的建议。我知道

表的索引和更新顺序会导致死锁。我的问题是,是否可以免费获得一个大的应用程序死锁?如果是,请与我分享如何确保

;什么类型的指导方针/规则要确保

表总是在存储过程时以正确的顺序更新,

触发器,并且直接查询可以同时命中数据库时间。


如果无法保证无死锁,那么听起来我们需要

将重试块放入代码中 - 别无他法。


希望再次收到您的回复。再次感谢。


" Andrew J. Kelly" <平方************ @ shadhawk.com>在消息中写道

news:uT ************** @ TK2MSFTNGP12.phx.gbl ...

大多数死锁是由于表格的顺序不良索引和不一致的更新。您可能希望更多地关注数据库
架构和代码与C#代码。

-
Andrew J. Kelly SQL MVP

"曾" <泽****** @ hotmail.com>在消息中写道
新闻:%2 **************** @ TK2MSFTNGP14.phx.gbl ...



我的C#Web应用程序越大,我需要放置更多的地方来重复执行代码,以确保可能遇到数据库死锁的操作是重新运行(重试)3-4次并放弃,如果它仍然处于僵局之后。我很确定很多有经验的人已经在某处以某种方式解决了这个问题。有没有替代
呢?感谢您的意见和建议。




我认为没有办法使应用程序无死锁,但你可以肯定做一些事情,以防止大多数事件发生。也许这些

会有所帮助:

http://www.sql-server-performance.com/deadlocks.asp
http://www.sql-server-performance.co...ql_locking.asp
http://support.microsoft.com/kb/q169960/
http://www.codeproject.com/cs/database/sqldodont.asp


-

Andrew J. Kelly SQL MVP

" Zeng" <泽****** @ hotmail.com>在消息中写道

新闻:eG ************** @ TK2MSFTNGP10.phx.gbl ...

感谢您的建议。我知道
表的索引和更新顺序会导致死锁。我的问题是,是否可以免费使用大型应用程序死锁?如果是,请与我分享提示
如何确保;当存在存储过程,触发器和直接查询可以同时命中数据库时,要遵循什么类型的准则/规则以确保
表始终以正确的顺序更新。
将重试块放入代码中 - 别无他法。

希望听到从你这里回来,再次感谢。

Andrew J. Kelly <平方************ @ shadhawk.com>在消息中写道
新闻:uT ************** @ TK2MSFTNGP12.phx.gbl ...

大多数死锁是由于索引不良和不一致造成的以表格的顺序更新。您可能希望更多地关注数据库
架构和代码与C#代码。

-
Andrew J. Kelly SQL MVP

"曾" <泽****** @ hotmail.com>在消息中写道
新闻:%2 **************** @ TK2MSFTNGP14.phx.gbl ...

>
>
>我的C#网络应用程序越大,我需要放置的地方越多
>
>繁琐的重试代码块,以确保可以运行的操作
>进入
>数据库死锁重新运行(重试)3-4次,如果在
>之后放弃
>它仍处于僵局。我很确定很多有经验的人出来
>某种程度上已经解决了这个问题。有替代品吗? >感谢您的意见和建议。
>
>
>





Hi,

The bigger my C# web-application gets, the more places I need to put in the
tedious retrying block of code to make sure operations that can run into
database deadlocks are re-run (retried) 3-4 times and give up if after that
it''s still in deadlock. I''m very sure that many experienced people out
there already deal with this issue somehow. Is there an alternative to it?
Thanks for your comments and suggestions.

解决方案

Most deadlocks are due to poor indexing and inconsistent updating in the
order of the tables. You may want to concentrate more on the database
schema and code vs. the C# code.

--
Andrew J. Kelly SQL MVP
"Zeng" <Ze******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...

Hi,

The bigger my C# web-application gets, the more places I need to put in
the
tedious retrying block of code to make sure operations that can run into
database deadlocks are re-run (retried) 3-4 times and give up if after
that
it''s still in deadlock. I''m very sure that many experienced people out
there already deal with this issue somehow. Is there an alternative to it?
Thanks for your comments and suggestions.



Thanks for the advice. I understand that indexing and update order of the
tables contribute to deadlocks. My question is is it possible to make a
large application deadlock free? If yes, please share the tips with me how
to ensure that; what type of guidelines/disciplines to follow to ensure
tables are always updated in correct order when there are storeprocedures,
triggers, and direct queries can hit the db at the same time.

If deadlock free is not guaranteed, then it sounds to me that we would need
to put retrying blocks into the code - no other way around.

Hope to hear back from you, thanks again.

"Andrew J. Kelly" <sq************@shadhawk.com> wrote in message
news:uT**************@TK2MSFTNGP12.phx.gbl...

Most deadlocks are due to poor indexing and inconsistent updating in the
order of the tables. You may want to concentrate more on the database
schema and code vs. the C# code.

--
Andrew J. Kelly SQL MVP
"Zeng" <Ze******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...

Hi,

The bigger my C# web-application gets, the more places I need to put in
the
tedious retrying block of code to make sure operations that can run into
database deadlocks are re-run (retried) 3-4 times and give up if after
that
it''s still in deadlock. I''m very sure that many experienced people out
there already deal with this issue somehow. Is there an alternative to it? Thanks for your comments and suggestions.




I don''t think there is ever a way to make an app deadlock free but you can
certainly do some things to prevent most occurrences of them. Maybe these
will help:

http://www.sql-server-performance.com/deadlocks.asp
http://www.sql-server-performance.co...ql_locking.asp
http://support.microsoft.com/kb/q169960/
http://www.codeproject.com/cs/database/sqldodont.asp

--
Andrew J. Kelly SQL MVP
"Zeng" <Ze******@hotmail.com> wrote in message
news:eG**************@TK2MSFTNGP10.phx.gbl...

Thanks for the advice. I understand that indexing and update order of the
tables contribute to deadlocks. My question is is it possible to make a
large application deadlock free? If yes, please share the tips with me
how
to ensure that; what type of guidelines/disciplines to follow to ensure
tables are always updated in correct order when there are storeprocedures,
triggers, and direct queries can hit the db at the same time.

If deadlock free is not guaranteed, then it sounds to me that we would
need
to put retrying blocks into the code - no other way around.

Hope to hear back from you, thanks again.

"Andrew J. Kelly" <sq************@shadhawk.com> wrote in message
news:uT**************@TK2MSFTNGP12.phx.gbl...

Most deadlocks are due to poor indexing and inconsistent updating in the
order of the tables. You may want to concentrate more on the database
schema and code vs. the C# code.

--
Andrew J. Kelly SQL MVP
"Zeng" <Ze******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...

> Hi,
>
> The bigger my C# web-application gets, the more places I need to put in
> the
> tedious retrying block of code to make sure operations that can run
> into
> database deadlocks are re-run (retried) 3-4 times and give up if after
> that
> it''s still in deadlock. I''m very sure that many experienced people out
> there already deal with this issue somehow. Is there an alternative to it? > Thanks for your comments and suggestions.
>
>
>





这篇关于死锁 - 重试交易的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆