cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Problem with apoc.cypher.parallel2

Greeting!

We are using neo4 community/enterprise as a primary database for our e-com platform.

We have noticed some strange behavior of apoc.cypher.parallel/apoc.cypher.parallel2 we want to question.

The example code is below (cleared the code a bit, community edition):

MATCH (parent :query_object {oid: $parentobjectoid})-[first_relation]->(child :query_object {oid: $childobjectoid})
                    WHERE type(first_relation) = $relationtype

                    CALL apoc.path.subgraphNodes(parent, {
                        beginSequenceAtStart: true,
                        minLevel: 0,
                        relationshipFilter: $process_relation_to
                    })
                    YIELD node AS object
                    WITH DISTINCT object, child, parent
                    WITH COLLECT({node: object, key: $to}) AS nodes, child, parent
                    CALL apoc.path.subgraphNodes(child, {
                        beginSequenceAtStart: true,
                        minLevel: 0,
                        relationshipFilter: $process_relation_from
                    })
                    YIELD node AS object
                    WITH DISTINCT object, nodes, child, parent
                    WITH nodes + COLLECT({node: object, key: $from}) AS nodes_map, child, parent


                    CALL apoc.cypher.mapParallel2(
                    '
                        WITH _.node AS object, child, parent,
                        CASE _.key = $to WHEN true THEN $processRelationTypesDirectStr ELSE $ReverseStr END AS process_relations,
                        CASE _.key = $to WHEN true THEN $process_relation_from ELSE $process_relation_to END AS process_relation_direction

                        CALL apoc.neighbors.athop(object, process_relations, 1)
                        YIELD node

                        RETURN node
                    ',
                    {processRelationTypesDirectStr:$processRelationTypesDirectStr, inheritRelationTypesReverseStr:$inheritRelationTypesReverseStr, child:child, parent:parent,
                    reverse:$reverse, account_access_groups:$account_access_groups, process_relation_from:$process_relation_from, process_relation_to:$process_relation_to,
                    to:$to, from:$from
                    }, nodes_map, 4) YIELD value AS value_map

                    RETURN value_map AS value

Execution of this code (browser/rest api/python driver) leads to "This transaction has already been closed" error. As far as we see the problem relates to calling apoc.neighbors.athop (or another apoc function) inside of mapParallel2 fragment (works fine without it).

The same code with apoc.cypher.mapParallel seems to work fine, however we do not notice any performance gains, compared to serial execution.

So the question is - is the mentioned mapParallel2 behavior intended or there are some settings/hacks we have missed?

Thanks in advance, Dmitry.

0 REPLIES 0