neo4j-apoc-procedures icon indicating copy to clipboard operation
neo4j-apoc-procedures copied to clipboard

Exception thrown when using `apoc.load.jdbc` about trying to close the connection before transaction is complete

Open arquadrado opened this issue 2 years ago • 4 comments

Specifications (Mandatory)

I have a neo4j cluster with 3 nodes and I am running an apoc procedure (apoc.load.jdbc) using Neo4J Desktop to update a neo4j database based on a db2 database but whenever I run the query (even the first time after restarting the cluster) I get the following exception about closing the connection:

Error closing b: com.ibm.db2.jcc.t4.b@38253d38 [jcc][t4][10251][10308][4.19.77] java.sql.Connection.close() requested while a transaction is in progress on the connection. The transaction remains active, and the connection cannot be closed. ERRORCODE=-4471, SQLSTATE=nullcom.ibm.db2.jcc.am.SqlException: [jcc][t4][10251][10308][4.19.77] java.sql.Connection.close() requested while a transaction is in progress on the connection. The transaction remains active, and the connection cannot be closed. ERRORCODE=-4471, SQLSTATE=null at com.ibm.db2.jcc.am.b4.a(b4.java:731)

Expected Behavior (Mandatory)

The expected behavior is for the procedure to close the connection only after the transaction has completed and not throw the above mentioned exception.

Actual Behavior (Mandatory)

The procedure tries to close the connection while the transaction remains active which leaves the connection open.

How to Reproduce the Problem

Having a cluster with nodes based on the neo4j docker image and do a query as simple as CALL apoc.load.jdbc('url, 'customer') and a db2 (or any sql db?)

Steps (Mandatory)

  1. Set up a reachable sql database
  2. Set up a neo4j cluster
  3. Execute the query CALL apoc.load.jdbc('url, 'customer') in Neo4J Desktop
  4. Check the logs of the nodes

Currently used versions

Versions

  • OS: Debian 10
  • Neo4j: 3.5.2-enterprise
  • Neo4j-Apoc: 3.5.0.1

EDIT:

Updating the version of neo4j to 4.4.16-enterprise and neo4j-apoc to 4.4.0.13 does not solve the issue.

arquadrado avatar Feb 01 '23 09:02 arquadrado

Thanks for reporting, I've added a ticket for this for someone to investigate :)

gem-neo4j avatar Feb 01 '23 12:02 gem-neo4j

In the meanwhile I made some discoveries regarding this issue. I tried doing the same thing with a different database (postgres) and I did not encounter any issue which led me to conclude that the problem was the database, in this case the db2.

After further investigation I discovered that we were using db2jcc4 version 10+ which was not compatible with the version of the db2 (9.1.0.9). I then tried to find a jdbc driver compatible with this archaic db and was able to found a jar that is supposedly compatible which I included in the /plugins of the neo4j node. Now I have a new problem when I run the apoc query. It cannot find the jdbc driver and as a consequence cannot even execute the query in the first place.

Does anyone has an idea why that might be? Is it possible that the neo4j apoc cannot recognize this older driver? I tried to downgrade the version of neo4j and apoc but then I can even do the query from the neo4j desktop browser since it says that "the database is not compatible with multiple databases" or something of the kind.

Any help or lead would be very much appreciated!

arquadrado avatar Feb 02 '23 17:02 arquadrado

Posting the results of my last efforts here:

After trying every combination of versions (neo4j, db2jcc driver) I could I decided to create a local docker environment running a db2 instance in its last version (11.5) and a single neo4j node (5.4.0) and I still got the error about trying to close the connection while the transaction is active when executing a simple apoc.load.jdbc(url, 'select * from table') procedure.

As I mentioned before this does not happen when using a different database e.g. postgres which leads me to believe that is an issue of integration between neo4j and db2.

For reference, here's the docker-compose.yaml which materialized my last attempt at this:

version: "3.9"
networks: {stack: {}}
services:

  neo4j:
    image: neo4j:5.4.0
    networks: ['stack']
    ports:
      - "7474:7474"
      - "7687:7687"
    volumes:
      - ./neo4j/data:/data
      - ./neo4j/logs:/logs
      - ./neo4j/import:/var/lib/neo4j/import
      - ./neo4j/plugins:/plugins
    environment:
      NEO4J_AUTH: neo4j/password

  mydb2:
    image: ibmcom/db2:11.5.8.0
    networks: ['stack']
    ports:
      - "50000:50000"
    environment:
      LICENSE: "accept"
      DB2INST1_PASSWORD: "neo4jpoc"
      DBNAME: "testdb"
    volumes:
      - ./db2/data:/database
    privileged: true

Since unfortunately I cannot just use a different db I will need to find an alternative for neo4j while this issue is not addressed.

I hope this information helps tackling the issue and contributes to a solution soon.

Thank you.

arquadrado avatar Feb 03 '23 17:02 arquadrado

@arquadrado I tried the docker-compose you provided, but I can't replicate the error. I also tested with other neo4j versions but with no problems.

I think the problem may be due to some value or data type present in your database. If possible, can you share your database or a sample that can replicate the problem?

vga91 avatar Jan 14 '24 14:01 vga91