cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Getting "The transaction has been closed." error while projecting a subgraph with GDS

Alexx
Node Link

Hi!

I'm trying to provide a WCC (weakly connected components) analysis for my graph

It's very big. I'm trying to make a projection of my graph with

gds.graph.project.cypher(MY_QUERY)

But it doesn't work and returns the following:

Failed to invoke procedure `gds.graph.project.cypher`: Caused by: org.neo4j.graphdb.NotInTransactionException: The transaction has been closed.

And a funny moment is that when I manually reduce number of nodes in my projection it does work

So question 1
How can I avoid this error?

Question 2 (optional)

Further on, if my main graph gets some new relationships, do I have to start the whole procedure again? Or I can somehow use the results, computed 1 step before
Or maybe I should use something else?

Thank u in advance, badly need your help - I'm already about to give in

2 ACCEPTED SOLUTIONS

I don't see an obvious reason for an 'out of transaction' error.  What happens when you run the node and relationship queries in the browser.

The only comment I have is I would think the 'with [a, a2] as a1' statement should follow the 'where' clause, as I would think the other variables the query references in the 'where' clause are out of scope when executed in this order.  It's odd, but the query plan does show all the variables being projected through the 'with' clause. 

View solution in original post

I just thought of something. Your relationship query returns source and target ids in the second match of the union, but these don't correspond to the ids of the nodes related by a relationship. I don't think this is legit.  Try your projection without this part of the relationship query. 

That error is occurring in the gds library. It would occur if the code tries to access a node outside the transaction that was used to find the node. 

View solution in original post

11 REPLIES 11

TrevorS
Community Team
Community Team

Hello @Alexx

I found this other post with a similar error message and how to resolve it.
https://community.neo4j.com/t5/drivers-stacks/notintransactionexception-in-neo4j-4-0-3-embedded/m-p/...
Can you let me know if this helps you?
Thanks!

TrevorS
Community Specialist

Hi, @TrevorS!

Thank you for reply

No, it doesn't help me.

The problem is that i'm bad at neo4j - not googling

Yeah, we have the same error msg, but am I using java? Can I break my request into parts to execute Weakly Connected Components algorithm?

I need just to make a projection for an existing graph. And there it fails

Maybe I still don't get smth?
Maybe I should give u more info about the code?

Can yo post your projection query that fails? 

@glilienfield, Hi!

Yeah, sure, I'm afraid, it's a bit scary but I'll try to explain if you'd like to

 

CALL gds.graph.project.cypher(
'myGraph_1',
"MATCH (a)
where (labels(a)=['Taxi'] and (a.taxi_type = 'type_1')) or (labels(a)=['Address'])
return id(a) as id
UNION
MATCH (a:Address) -[p1:Path]->(tx:Taxi)-[p2:Path]->(a2:Address)
with [a, a2] as a1
where (labels(tx)=['taxi'] and (tx.taxi_type = 'type_2'))
and p2.amount < 0.001
UNWIND a1 as a3
Return id(a3) as id",
"MATCH (a1)-[r]-(a2) WHERE a1.taxi_type = 'type_1' RETURN id(a1) as source, id(a2) as target
UNION
MATCH (a:Address) -[p1:Path]->(tx:Taxi)-[p2:Path]->(a2:Address)
where (labels(tx)=['Taxi'] and (tx.taxi_type = 'type_2'))
and p2.amount < 0.001
Return id(a) as source, id(a2) as target
"
)
YIELD graphName AS graph, nodeQuery, nodeCount AS nodes, relationshipQuery, relationshipCount AS rels;
 
And this is exactly where it fails
Later on, I was going to apply gds.wcc.stream to this projection

And again, thank u for help and attention! I appreciate that!

I don't see an obvious reason for an 'out of transaction' error.  What happens when you run the node and relationship queries in the browser.

The only comment I have is I would think the 'with [a, a2] as a1' statement should follow the 'where' clause, as I would think the other variables the query references in the 'where' clause are out of scope when executed in this order.  It's odd, but the query plan does show all the variables being projected through the 'with' clause. 

When i run both node and relationship, they work fine
Very slow, but still fine

And a funny thing by the way:
Before that I used to try to execute the same code, but instead of "taxi_type" i just passed the ids  as an argument (via jupyter notebook)

And the projection did execute with a small amount of ids (about 100), and failed on bigger numbers(1000+)

I thought, the problem might be because of a huge length of argument, so I created those types directly on Neo
But still it fails ;(

And well, I actually don't even get the meaning of this error - if it didn't have enough space, ok, that would be clrear
But why the transaction is closed?)

Ah yeah, and I tried putting "with [a, a2] as a1" after where - still the same

I just thought of something. Your relationship query returns source and target ids in the second match of the union, but these don't correspond to the ids of the nodes related by a relationship. I don't think this is legit.  Try your projection without this part of the relationship query. 

That error is occurring in the gds library. It would occur if the code tries to access a node outside the transaction that was used to find the node. 

@glilienfield, just to make sure I got you right: were you talking about this part of code?

UNION
MATCH (a:Address) -[p1:Path]->(tx:Taxi)-[p2:Path]->(a2:Address)
where (labels(tx)=['Taxi'] and (tx.taxi_type = 'type_2'))
and p2.amount < 0.001
Return id(a) as source, id(a2) as target

I've removed that but still the same error. And also tried to remove those part after UNION in both: nodes and relationship queries - still the same

And besides, I don't get how can that be:
"...source and target ids in the second match of the union, but these don't correspond to the ids of the nodes related by a relationship"

To me, I match all the nodes I'm interested in the first query, just as a set of nodes
And then I match the pairs of nodes (actually I don't need them to be oriented)

Or am I mistaken?

Yeah, @glilienfield, you were right!

I've changed the first parts of queries (before "UNION") and now that works!

So the problem was that I had several unused node ids that were not mentioned in relations?
But what if I wanted to scan any nodes without relations, to receive all components, even containing just 1 node?

Anyway, thank u so much!)