Issue on calling custom procedure created by apoc.custom.asProcedure()

Hello,

I'm trying to use apoc.cusom.asProcedure to create my own custom proc. The procedure is created successfully and I can see it listed when I run CALL apoc.cusom.list in the Neo4J browser. However, I am never able to call the custom procedure reliably. It works the first couple of times, and then it throws an error.

Here is the query to register the procedure:

CALL apoc.custom.asProcedure('linkTypes',
'MATCH (:LinkCategory {Name: $linkCategory})-[:Contains]->(lt:LinkType) RETURN collect(lt.Name) AS linkTypeNames',
'read', [['linkTypeNames', 'LIST TYPE']], [['linkCategory', 'STRING']],
'Return the link types for a particular link category')

It is a very simple query, that will retrieve the different relationship types mapped to one relationship category.
After registration, I call my custom proc like this:

CALL custom.linkTypes('EXCLUDE') YIELD linkTypeNames

I get the expected result the first couple of times when I run this. But on subsequent requests, I get this:


Sometimes it takes 10-12 tries to get it to fail. And sometimes, just the 2nd try is enough.

To get the procedure to work again, I do a CALL dbms.clearQueryCaches and re-register the proedure, until the same issue happens again.

This is the excerpt from the debug.log:

2020-04-27 14:55:43.790+0000 INFO [o.n.k.i.p.Procedures] Called dbms.clearQueryCaches(): Query caches successfully cleared of 22 queries.
2020-04-27 14:56:45.849+0000 INFO [o.n.k.i.p.Procedures] Called dbms.clearQueryCaches(): Query caches successfully cleared of 8 queries.
2020-04-27 14:57:00.623+0000 ERROR [o.n.b.v.r.ErrorReporter] Client triggered an unexpected error [Neo.DatabaseError.General.UnknownError]: There is no procedure with the name `custom.linkTypes` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed., reference b29a3e6a-fa39-46ac-aac8-d76d3c2e1043.
2020-04-27 14:57:00.625+0000 ERROR [o.n.b.v.r.ErrorReporter] Client triggered an unexpected error [Neo.DatabaseError.General.UnknownError]: There is no procedure with the name `custom.linkTypes` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed., reference b29a3e6a-fa39-46ac-aac8-d76d3c2e1043. There is no procedure with the name `custom.linkTypes` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.
org.neo4j.graphdb.QueryExecutionException: There is no procedure with the name `custom.linkTypes` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.
	at apoc.custom.CypherProcedures$CustomStatementRegistry$2.apply(CypherProcedures.java:231)
	at org.neo4j.kernel.impl.proc.ProcedureRegistry.callProcedure(ProcedureRegistry.java:219)
	at org.neo4j.kernel.impl.proc.Procedures.callProcedure(Procedures.java:290)
	at org.neo4j.kernel.impl.newapi.AllStoreHolder.callProcedure(AllStoreHolder.java:1098)
	at org.neo4j.kernel.impl.newapi.AllStoreHolder.procedureCallRead(AllStoreHolder.java:863)
	at org.neo4j.cypher.internal.runtime.interpreted.CallSupport$$anonfun$2.apply(CallSupport.scala:62)
	at org.neo4j.cypher.internal.runtime.interpreted.CallSupport$$anonfun$2.apply(CallSupport.scala:62)
	at org.neo4j.cypher.internal.runtime.interpreted.CallSupport$.callProcedure(CallSupport.scala:167)
	at org.neo4j.cypher.internal.runtime.interpreted.CallSupport$.callReadOnlyProcedure(CallSupport.scala:64)
	at org.neo4j.cypher.internal.runtime.interpreted.TransactionBoundQueryContext.callReadOnlyProcedure(TransactionBoundQueryContext.scala:974)
	at org.neo4j.cypher.internal.compatibility.v3_5.ExceptionTranslatingQueryContext$$anonfun$callReadOnlyProcedure$1.apply(ExceptionTranslatingQueryContext.scala:166)
	at org.neo4j.cypher.internal.compatibility.v3_5.ExceptionTranslatingQueryContext$$anonfun$callReadOnlyProcedure$1.apply(ExceptionTranslatingQueryContext.scala:166)
	at org.neo4j.cypher.internal.compatibility.v3_5.ExceptionTranslationSupport$class.translateException(ExceptionTranslationSupport.scala:33)
	at org.neo4j.cypher.internal.compatibility.v3_5.ExceptionTranslatingQueryContext.translateException(ExceptionTranslatingQueryContext.scala:42)
	at org.neo4j.cypher.internal.compatibility.v3_5.ExceptionTranslationSupport$class.translateIterator(ExceptionTranslationSupport.scala:47)
	at org.neo4j.cypher.internal.compatibility.v3_5.ExceptionTranslatingQueryContext.translateIterator(ExceptionTranslatingQueryContext.scala:42)
	at org.neo4j.cypher.internal.compatibility.v3_5.ExceptionTranslatingQueryContext.callReadOnlyProcedure(ExceptionTranslatingQueryContext.scala:166)
	at org.neo4j.cypher.internal.runtime.LazyReadOnlyCallMode.callProcedure(ProcedureCallMode.scala:48)
	at org.neo4j.cypher.internal.compatibility.v3_5.runtime.executionplan.procs.ProcedureCallRuntimeResult.executeCall(ProcedureCallRuntimeResult.scala:72)
	at org.neo4j.cypher.internal.compatibility.v3_5.runtime.executionplan.procs.ProcedureCallRuntimeResult.<init>(ProcedureCallRuntimeResult.scala:66)
	at org.neo4j.cypher.internal.compatibility.v3_5.runtime.executionplan.procs.ProcedureCallExecutionPlan.run(ProcedureCallExecutionPlan.scala:88)
	at org.neo4j.cypher.internal.compatibility.CypherCurrentCompiler$CypherExecutableQuery$$anonfun$execute$3.apply(CypherCurrentCompiler.scala:204)
	at org.neo4j.cypher.internal.compatibility.CypherCurrentCompiler$CypherExecutableQuery$$anonfun$execute$3.apply(CypherCurrentCompiler.scala:190)
	at org.neo4j.cypher.exceptionHandler$runSafely$.apply(exceptionHandler.scala:89)
	at org.neo4j.cypher.internal.compatibility.CypherCurrentCompiler$CypherExecutableQuery.execute(CypherCurrentCompiler.scala:223)
	at org.neo4j.cypher.internal.ExecutionEngine.execute(ExecutionEngine.scala:101)
	at org.neo4j.cypher.internal.javacompat.ExecutionEngine.executeQuery(ExecutionEngine.java:85)
	at org.neo4j.bolt.v1.runtime.TransactionStateMachineV1SPI$BoltResultHandleV1.start(TransactionStateMachineV1SPI.java:189)
	at org.neo4j.bolt.v1.runtime.TransactionStateMachine$State.startExecution(TransactionStateMachine.java:506)
	at org.neo4j.bolt.v1.runtime.TransactionStateMachine$State$2.run(TransactionStateMachine.java:385)
	at org.neo4j.bolt.v1.runtime.TransactionStateMachine.run(TransactionStateMachine.java:110)
	at org.neo4j.bolt.v1.runtime.TransactionStateMachine.run(TransactionStateMachine.java:98)
	at org.neo4j.bolt.v3.runtime.TransactionReadyState.processRunMessage(TransactionReadyState.java:82)
	at org.neo4j.bolt.v3.runtime.TransactionReadyState.processUnsafe(TransactionReadyState.java:49)
	at org.neo4j.bolt.v3.runtime.FailSafeBoltStateMachineState.process(FailSafeBoltStateMachineState.java:48)
	at org.neo4j.bolt.v1.runtime.BoltStateMachineV1.nextState(BoltStateMachineV1.java:144)
	at org.neo4j.bolt.v1.runtime.BoltStateMachineV1.process(BoltStateMachineV1.java:92)
	at org.neo4j.bolt.messaging.BoltRequestMessageReader.lambda$doRead$1(BoltRequestMessageReader.java:89)
	at org.neo4j.bolt.runtime.MetricsReportingBoltConnection.lambda$enqueue$0(MetricsReportingBoltConnection.java:68)
	at org.neo4j.bolt.runtime.DefaultBoltConnection.processNextBatch(DefaultBoltConnection.java:191)
	at org.neo4j.bolt.runtime.MetricsReportingBoltConnection.processNextBatch(MetricsReportingBoltConnection.java:86)
	at org.neo4j.bolt.runtime.DefaultBoltConnection.processNextBatch(DefaultBoltConnection.java:139)
	at org.neo4j.bolt.runtime.ExecutorBoltScheduler.executeBatch(ExecutorBoltScheduler.java:171)
	at org.neo4j.bolt.runtime.ExecutorBoltScheduler.lambda$scheduleBatchOrHandleError$2(ExecutorBoltScheduler.java:154)
	at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

I really do not understand why this is happening, or whether I'm doing something wrong. I tried using apoc.custom.asFunction as well, and the same thing happens. Help is greatly appreciated. Thanks in advance!

General info:

  • Neo4j: 3.5.15, 3.5.12 - Docker images
  • Apoc: apoc-3.5.0.9-all.jar
  • OS: MacOS Browser: Chrome
  • Driver: Neo4j Official Go Driver 1.7.4
  • Procedures: apoc.custom.asProcedure(), apoc.custom.asFunction()

Is this a cluster deployment, or single instance? Do you have any logs showing the docker container restarting, or is the same instance being used throughout without any kind of recovery or restarting?

It's a single instance. No restarts or recovery.

Testing on another server led me to believe the issue was localised to my instance. I removed the data folder so that it would be created again on starting neo4j, and now it works.