neo4j-ruby-driver icon indicating copy to clipboard operation
neo4j-ruby-driver copied to clipboard

Nested transaction hangs

Open petergebala opened this issue 3 years ago • 2 comments
trafficstars

I have a weird issue. Our code hangs whenever we try: Example:

ActiveRecord::Base.transaction do
  ActiveGraph::Base.write_transaction do
     User.first # User is an ActiveRecord object. Hangs here
  end
end

From my investigation looks like it hangs inside Async gem and the only other gem that is using it is neo4j-ruby-driver.

Ruby: 3.1 Rails: 7.0.4 Neo4j version 4.4.0.12 Neo4j ruby driver version: 4.4.0.beta-1

petergebala avatar Nov 07 '22 15:11 petergebala

@petergebala that's an interesting issue. However, neo4j does not support nested transactions not to mention nested with within different database transactions. One thing to note is that the block provided to write_transaction runs as a transaction function that is subject to retries. So the code within the block must be idempotent which is another reason why what you attempt is difficult to achieve. Now we are intrigued about the reason for the hang but do not have enough time to research the rather academic question.

klobuczek avatar Nov 14 '22 22:11 klobuczek

Thanks for the reply @klobuczek.

To give you some context. Currently, we are using neo4j 3.5 with ruby 2.7 and rails 6.1. We want to migrate to a newer version of neo4j - 4.4. That forces us to upgrade ruby (3.1) and rails (7.0.x). Existing code base (neo4j 3.5, older driver, code with nested transactions) works just fine and as expected. So for me, it looks like regression over past versions. Transactions are useful to keep data in sync between different DBs. Also, it sounds dangerous that ActiveGraph affects in some way ActiveRecord.

Of course, above example was just a simplification of the logic that we have. It does not matter if we put there write_transaction or read_transaction. What is more code inside the block doesn't raise any error (It is simple select).

We will try to debug this issue, but it will take probably more time for us. We are not familiar with the driver code base yet.

petergebala avatar Nov 15 '22 06:11 petergebala