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.

How to set timeout in drivers (py2neo or neo4j)

Hi there,
I'm connecting to the neo4j sandbox using google colab. Some queries are ok, but some result in timeout error.
I want to execute a query using neo4j driver (same situation with py2neo), but it gives this error after about 45 seconds:

{code: Neo.ClientError.Transaction.TransactionTimedOut} {message: The transaction has been terminated. Retry your operation in a new transaction, and you should see a successful result. The transaction has not completed within the specified timeout (dbms.transaction.timeout). You may want to retry with a longer timeout. }

I tried using unit_of_work in two ways:

from neo4j import unit_of_work
@unit_of_work(timeout=240000) # 240,000 ms -> 240 s -> 4 mins
def execute(query):
    return graph.run(query)


and also

neo4j.unit_of_work(timeout=240000)
graph.run(query)


None them solved my problem.
I couldn't find any solutions for py2neo.

(I can use either of neo4j and py2neo drivers, if it is required.)
Thank you.

1 ACCEPTED SOLUTION

Hi,

there are two things going on here. Firstly, duration values in Python are typically given in seconds, not milliseconds. So you set the timeout to ~2,7 days. But that doesn't explain why the transaction still gets terminated that soon. As far as I'm aware, the server doesn't allow the client to increase the configured timeout, but only to decrease it. So you would have to increase the transaction timeout in the server configuration.

View solution in original post

3 REPLIES 3

Hi,

there are two things going on here. Firstly, duration values in Python are typically given in seconds, not milliseconds. So you set the timeout to ~2,7 days. But that doesn't explain why the transaction still gets terminated that soon. As far as I'm aware, the server doesn't allow the client to increase the configured timeout, but only to decrease it. So you would have to increase the transaction timeout in the server configuration.

Hi there,
Thanks for your comment. Seems that there's not much I can do.

As for the unit part, you are right it's second, not ms. I mixed that up with something else.

How to timeout in OGM? is there anything in ogm.properties?

My app is stuck here for an hr.

"pool-12-thread-1" #121 prio=5 os_prio=0 cpu=54819.50ms elapsed=23866.36s tid=0x00007f01b95db000 nid=0xea waiting on condition [0x00007f0049fe2000]
java.lang.Thread.State: WAITING (parking)
at jdk.internal.misc.Unsafe.park(java.base@11.0.10/Native Method)
- parking to wait for <0x000000069a99d260> (a java.util.concurrent.CompletableFuture$Signaller)
at java.util.concurrent.locks.LockSupport.park(java.base@11.0.10/LockSupport.java:194)
at java.util.concurrent.CompletableFuture$Signaller.block(java.base@11.0.10/CompletableFuture.java:1796)
at java.util.concurrent.ForkJoinPool.managedBlock(java.base@11.0.10/ForkJoinPool.java:3128)
at java.util.concurrent.CompletableFuture.waitingGet(java.base@11.0.10/CompletableFuture.java:1823)
at java.util.concurrent.CompletableFuture.get(java.base@11.0.10/CompletableFuture.java:1998)
at org.neo4j.driver.internal.util.Futures.blockingGet(Futures.java:128)
at org.neo4j.driver.internal.InternalResult.blockingGet(InternalResult.java:128)
at org.neo4j.driver.internal.InternalResult.hasNext(InternalResult.java:64)
at org.neo4j.ogm.drivers.bolt.response.GraphModelResponse.fetchNext(GraphModelResponse.java:42)
at org.neo4j.ogm.drivers.bolt.response.GraphModelResponse.fetchNext(GraphModelResponse.java:29)
at org.neo4j.ogm.drivers.bolt.response.BoltResponse.next(BoltResponse.java:48)
at org.neo4j.ogm.response.Response.toList(Response.java:43)
at org.neo4j.ogm.context.GraphRowModelMapper.map(GraphRowModelMapper.java:50)
at org.neo4j.ogm.session.delegates.LoadOneDelegate.lambda$load$0(LoadOneDelegate.java:89)
at org.neo4j.ogm.session.delegates.LoadOneDelegate$$Lambda$382/0x0000000840704440.doInTransaction(Unknown Source)
at org.neo4j.ogm.session.Neo4jSession.doInTransaction(Neo4jSession.java:590)
at org.neo4j.ogm.session.Neo4jSession.doInTransaction(Neo4jSession.java:564)
at org.neo4j.ogm.session.delegates.LoadOneDelegate.load(LoadOneDelegate.java:86)
at org.neo4j.ogm.session.Neo4jSession.load(Neo4jSession.java:189)