question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can readTransaction and writeTransaction after a session.close()?

See original GitHub issue

With my NestJs application, I want to create a Session by request and close it at the end of client request of my API. Unfortunately, I try this:

let session = this.neo4j.session();
session.close();
session.readTransaction(tx=>...);

And it works… I have my data. What is the mechanism behind all this? readTransaction and writeTransaction reopen the session? How can be sure to close really a session? Regards.

Neo4j Version: 3.5.3 Neo4j Mode: Single instance
Driver version: JS driver 1.7.6 Operating System: Linux Mint 19.2

Steps to reproduce

  1. Create a session
  2. Close it
  3. Run a query with readTransaction or writeTransaction
  4. Look the result

Expected behavior

Throw exception?

Actual behavior

I don’t know… I think readTransaction or writeTransaction reopen session.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
zhenlineocommented, Nov 29, 2019

Hi @mehdikwa,

In 1.7, if you give a callback in session.close(callback), then once the callback is done, then all session resources (such as connections) are all released (return to a connection pool on driver).

The threads used on server is not strictly related to the connections the Neo4j server handles. Also the server has many thread pools besides the pool used by bolt server. If you want to change the default thread pool settings of bolt server, here are some instructions to change them.

0reactions
mehdikwacommented, Nov 29, 2019

Hello,

If the session is still alive after closing it, will it mean that the session keeps an opened slot in the pool of connections and affects number of threads used in the cluster ? We are experiencing this behavior in a sense where we open a connexion for every function and closing it after return. But seems threads on server keeps increasing till overloading CPU usage.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Difference between session.run and session.readTra... - Neo4j
Solved: In Javascript driver, what is the difference between running Cypher queries using session.run() and session.readTransaction((tx) - 46037.
Read more >
How to properly return a StatementResult with a Transaction ...
Should I keep using the execute() function, the session.writeTransaction() function ? It seems to me that there is a lot of way of...
Read more >
Session (Neo4j Java Driver 4.3.3 API) - Javadoc.io
Execute a unit of work in a managed read transaction. This transaction will automatically be committed unless an exception is thrown during query...
Read more >
org.neo4j.driver.v1.Session.writeTransaction java ... - Tabnine
Transaction will automatically be committed unless exception is thrown from the unit of work itself or from Transaction#close() or transaction is explicitly ...
Read more >
About transactions | Cloud Spanner
Read-only transactions do not need to be committed and do not take locks. ... The following shows how to execute a read-write transaction:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found