Deadlock Handling

46 views
Skip to first unread message

James Kim

unread,
Jun 25, 2014, 1:23:25 PM6/25/14
to neo4j...@googlegroups.com
I am trying to handle deadlocks and I don't see a DeadlockDetectedException in the driver. Currently I am trying to handle it by catching the NeoException.

            catch (NeoException ex)
            {
                if (ex.NeoExceptionName == "DeadlockDetectedException")
                {
                    // Add to retry queue
                }

                
            }

Is this the correct way to handle it or if there a better way?

Thanks.

Romiko van de dronker Derbynew

unread,
Jun 25, 2014, 6:12:50 PM6/25/14
to neo4j...@googlegroups.com

Perhaps better to avoid deadlocks all together,  something smells further up the chain. . Look there.

--
You received this message because you are subscribed to the Google Groups "Neo4jClient" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4jclient...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James Kim

unread,
Jun 26, 2014, 11:18:47 AM6/26/14
to neo4j...@googlegroups.com
There is nothing up the chain as the deadlocks are coming from a multi-threaded application that is doing quite a bit of data crunching to keep our old system and the new system in sync with each other. 

I would appreciate an answer to the question or if someone could point me to the documentation that shows what is being populated in the NeoException so I can handle the possible deadlocks.

Romiko van de dronker Derbynew

unread,
Jun 26, 2014, 5:54:20 PM6/26/14
to neo4j...@googlegroups.com

James Kim

unread,
Jun 26, 2014, 6:02:23 PM6/26/14
to neo4j...@googlegroups.com
We are developing in C# and the driver does not support batching at the moment. In order to speed up the processing we decided to multi-thread a maintenance process. The overall deadlocking is very low since, in most cases, the nodes that are being related don't need to be operated on in that task set. However, in some cases the nodes do result in a deadlock situation. This is either because of bad data or just the occasional relationship where a node that normally would not have a relationship has a relationship. Regardless, the question is, "What is the correct way to handle the DeadlockDetectedException when it does arise?"

Tatham Oddie

unread,
Jun 26, 2014, 10:41:09 PM6/26/14
to neo4j...@googlegroups.com

Hi James,

 

Another library author here.

 

The DeadlockException occurs on the Java side, and is then returned over REST as text. Whenever we receive an error from Neo, we just wrap it up in a NeoException on the .NET side.

 

There is no more structured way to do it than what you are doing.

 

I’ve thought about us trying to rehydrate the Java exceptions into fake .NET ones, but that seems like it would lead to its own confusion. Also, it would be susceptible to breakages as the text format is not a documented part of the API contract from Neo, so they always have the right to change their exception formatter.

 

--

Tatham Oddie

James Kim

unread,
Jun 27, 2014, 11:11:43 AM6/27/14
to neo4j...@googlegroups.com
Tatham,

Thanks for the reply. So I can assume that the line in my code (ex.NeoExceptionName == "DeadlockDetectedException") is correct? At least for the time being. Just need to make sure that the string I am checking is the right one. 

Thanks.

Tatham Oddie

unread,
Jun 29, 2014, 8:00:57 PM6/29/14
to neo4j...@googlegroups.com

The approach is correct.

 

I can’t guarantee the string though: that will just be whatever happens to come back over the API. J

Reply all
Reply to author
Forward
0 new messages