New Posts New Posts RSS Feed: Deadlock detection
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Deadlock detection

 Post Reply Post Reply
Author
ritaf View Drop Down
Newbie
Newbie


Joined: 23-Jan-2012
Posts: 5
Post Options Post Options   Quote ritaf Quote  Post ReplyReply Direct Link To This Post Topic: Deadlock detection
    Posted: 26-Jan-2012 at 10:00am

Hi,

I am a novice DevForce developer, so my question is probably very trivial.

Is there a way to detect deadlock errors (or to distinguish any other data provider errors) when EntityManager.SaveChanges/SaveChangesAsync fails? I want to retry saving changes if they fail due to the database deadlock.  When deadlock occurs I can see a particular type of exception on a server side in EntityServerSaveInspector.OnError as an InnerException but I am not sure if I can retry at this point.  On a client side, error is returned as a generic EntityManagerServerException and InnerException is not set.  I can see RemoteExceptionDetails but I cannot see the original error number, so I cannot make a determination that it’s a deadlock error.

Thank you,

Rita

Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 27-Jan-2012 at 1:55pm
Hi Rita,
 
In what circunstances do you anticipate these deadlocks? (on concurrency conflicts?)
Have you considered using optimistic concurrency? (more detais in the DevForce Resource Center)
 
Unfortunatelly, you won't be able to retry the save on the server once you get an error.
 
What particular type of inner exception are you getting on EntityServerSaveInterceptor.OnError? I tried to simulate a deadlock and ended up getting timeout errors due to non response from SQL Server.
 
 
Silvio.
 
 
 
 
Back to Top
ritaf View Drop Down
Newbie
Newbie


Joined: 23-Jan-2012
Posts: 5
Post Options Post Options   Quote ritaf Quote  Post ReplyReply Direct Link To This Post Posted: 27-Jan-2012 at 2:54pm

Hi Silvio,

 

 

We have done some optimization to prevent deadlocks.  But in case they still occur I want to add an ability for the application to retry the save.  I can retry calling SaveChangesAsync from the client but I need to have a way to determine that the error was in fact a deadlock error.  Currently, on a client I can only get exception message, stack and etc. (RemoteException properties of EntityManagerException) and generic FailureType.  I need to find something in the EntityManagerSaveException that will tell me the error number.

 

In case of a deadlock, EntityServerSaveInterceptor.OnError inner exception is System.Data.SqlClient.SqlException, error number 1205.

 

Thank you,

Rita

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down