Retry after OOME fail when Neo4j procedure called from Neo4j browser but not from cypher-shell

102 Views Asked by At

I have Java method deployed into dockerized Neo4j as standard stored procedure in plugin. The method sets new property to all nodes of some label. It fails with OutOfMemoryError since the JVM heap is not appropriately sized for committing everything in single transaction.

public class Foo {

    @Context
    public Transaction tx;

    @Procedure(value = "foo", mode = Mode.WRITE)
    public void foo() {
        System.out.println("ENTER");
        for (Node node : (Iterable<Node>) () -> tx.findNodes(Labels.label("Hoo"))) {
            node.setProperty("SOME_PROPERTY", new long[] {100L,200L});
        }
        System.out.println("EXIT");
    }
}

Let's call the method:

CALL foo();
  • When the method is called from Neo4j Browser on localhost:7474, the method exits but then it is called again:
ENTER
EXIT

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "neo4j.StorageMaintenance-3"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "neo4j.StorageMaintenance-2"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "qtp1566104673-43"
Exception in thread "neo4j.VmPauseMonitor-1" Exception in thread "neo4j.Scheduler-1" java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
2021-07-03 09:42:16.438+0000 WARN  
java.lang.OutOfMemoryError: Java heap space
Exception in thread "qtp1566104673-40" java.lang.OutOfMemoryError: Java heap space
ENTER
EXIT
  • When I docker exec into Neo4j container and call the method from cypher-shell, the method fails with OOME too, but there is no repeated call.

Why is the method called twice from Neo4j Browser? Is there some documentation or link to source code to support reasoning of such behavior?

(Please note the question is not how to fix OOME, currently it is successfully fixed to bulk processing in similar manner to apoc.periodic package.)

0

There are 0 best solutions below