Print Page | Close Window

Deadlock detection

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3235
Printed Date: 13-May-2026 at 2:01pm


Topic: Deadlock detection
Posted By: ritaf
Subject: Deadlock detection
Date 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




Replies:
Posted By: sbelini
Date 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 http://drc.ideablade.com/xwiki/bin/view/Documentation/save-concurrency - 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.
 
 
 
 


Posted By: ritaf
Date 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




Print Page | Close Window