Return ParameterNotFoundException by running the procedure i deployed

Question

when i run the procedure i deployed ,i got the message like this:

Neo.ClientError.Procedure.ProcedureCallFailed
Failed to invoke procedure `widdo.node.delete`: Caused by: org.neo4j.exceptions.ParameterNotFoundException: Expected parameter(s): ids

Version

Neo4j Browser version: 5.4.0

Neo4j Server version: 4.4.17

Neo4j Java Driver version : 4.4.9

Neo4j version : 4.4.9

Code

/**
 * delete procedure. using this, you can batch delete nodes and it`s relation ,which nodes has relation.
 *
 * @author XYL
 * @date 2023/02/27 18:44
 * @since 263.1.3.0
 */
public class DeleteProcedure {

    /**
     * tx.
     */
    @Context
    @IgnoreNeo4jVisibility
    public Transaction tx;

    public static class DeleteContainer {

        /**
         * the variable which to be return of this procedure.
         */
        @IgnoreNeo4jVisibility
        public Long count;

        /**
         * constructor has one param called count.
         *
         * @param count count
         */
        public DeleteContainer(final Long count) {
            this.count = count;
        }
    }

    /**
     * procedure named delete.
     * <p>
     * note that:
     * the parameter called idMap has one called label, and one called ids type of arrays ,another called config type of map
     *
     * @param label  label of which node will be delete
     * @param ids    ids which node will be deleted
     * @param config config of this procedure
     * @return java.util.stream.Stream<cn.widdo.starter.neo4j.plugins.procedures.DeleteProcedure.DeleteContainer>
     * @author XYL
     * @date 2023/02/27 18:59:51
     */
    @Procedure(name = "widdo.node.delete", mode = Mode.WRITE)
    @Description(value = "batch delete nodes and it`s relations, if the node has relations,return the count of deleted.")
    public Stream<DeleteContainer> delete(@Name("label") String label, @Name("ids") List<Long> ids, @Name("config") Map<String, Object> config) {

        final Long batchSize = Optional.ofNullable(config.get("batchSize")).map(s -> (Long) s).orElse(2000L);

        final boolean parallel = Optional.ofNullable(config.get("parallel")).map(s -> (boolean) s).orElse(true);

        final boolean iterateList = Optional.ofNullable(config.get("iterateList")).map(s -> (boolean) s).orElse(true);

        final String cypher = String.format("call apoc.periodic.iterate(\"MATCH (n:%s) where id(n) in $ids return n\",\n"
                + "\"detach delete n \",\n"
                + "{batchSize:$batchSize,parallel:$parallel,iterateList:$iterateList}) YIELD operations", label);

        final HashMap<String, Object> map = new HashMap<>(4);
        map.put("ids", ids);
        map.put("batchSize", batchSize);
        map.put("parallel", parallel);
        map.put("iterateList", iterateList);

        ResourceIterator<Long> nodes = tx.execute(cypher, map).columnAs("count");
        return nodes.stream().map(DeleteContainer::new);
    }
}

Result

Neo.ClientError.Procedure.ProcedureCallFailed
Failed to invoke procedure `widdo.node.delete`: Caused by: org.neo4j.exceptions.ParameterNotFoundException: Expected parameter(s): ids

Profile

Log

2023-02-28 06:49:15.187+0000 ERROR [o.n.b.t.p.ProtocolHandshaker] Fatal error occurred during protocol handshaking: [id: 0x90427195, L:/127.0.0.1:7687 - R:/127.0.0.1:52555]
java.lang.NullPointerException: null
	at io.netty.buffer.Unpooled.copiedBuffer(Unpooled.java:363) ~[netty-buffer-4.1.86.Final.jar:4.1.86.Final]
	at org.neo4j.bolt.transport.DiscoveryResponseHandler.channelRead(DiscoveryResponseHandler.java:60) ~[neo4j-bolt-4.4.17.jar:4.4.17]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) [netty-codec-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346) [netty-codec-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318) [netty-codec-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.handlerRemoved(ByteToMessageDecoder.java:266) [netty-codec-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:536) [netty-codec-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468) [netty-codec-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290) [netty-codec-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at org.neo4j.bolt.transport.pipeline.AuthenticationTimeoutHandler.channelRead(AuthenticationTimeoutHandler.java:58) [neo4j-bolt-4.4.17.jar:4.4.17]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) [netty-common-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.86.Final.jar:4.1.86.Final]
	at java.lang.Thread.run(Thread.java:832) [?:?]
2023-02-28 06:49:45.450+0000 ERROR [o.n.b.t.TransportSelectionHandler] Fatal error occurred when initialising pipeline: [id: 0xe0c8f9b3, L:/127.0.0.1:7687 ! R:/127.0.0.1:52557]
org.neo4j.bolt.runtime.BoltConnectionFatality: Terminated connection '[id: 0xe0c8f9b3, L:/127.0.0.1:7687 ! R:/127.0.0.1:52557]' as the client failed to authenticate within 30000 ms.
	at org.neo4j.bolt.transport.pipeline.AuthenticationTimeoutHandler.channelIdle(AuthenticationTimeoutHandler.java:78) ~[neo4j-bolt-4.4.17.jar:4.4.17]
	at io.netty.handler.timeout.IdleStateHandler$ReaderIdleTimeoutTask.run(IdleStateHandler.java:503) [netty-handler-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.handler.timeout.IdleStateHandler$AbstractIdleTask.run(IdleStateHandler.java:475) [netty-handler-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98) [netty-common-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:153) [netty-common-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) [netty-common-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) [netty-common-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) [netty-common-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569) [netty-transport-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) [netty-common-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.86.Final.jar:4.1.86.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.86.Final.jar:4.1.86.Final]
	at java.lang.Thread.run(Thread.java:832) [?:?]

somebody help !

Thanks

only_xyl

You don't pass in your parameters as params parameter to the apoc call.

In general I don't recommend calling the apoc procedure like this, as the apoc proc creates it's own threads and transactions, just call it form the top-level.
There are too many places where the handover and concurrency handling is tricky.

Also in your case you can also just use call-in-transactions.

If you have varying degrees I also recommend to delete the relationships first in same-sized batches and then the nodes, see the last example on the page

1 Like

Hi, @michael.hunger

   Thank you for your answer. I have a try about it and it solved my problem.

only_xyl