Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apoc.refactor.cloneSubgraph() clones survive transaction rollback #4227

Open
sshyshspsoft opened this issue Nov 13, 2024 · 1 comment
Open
Labels
core-functionality Adding new procedure, function or signature to APOC core

Comments

@sshyshspsoft
Copy link

Description

Same issue as in #3960 but with apoc.refactor.cloneSubgraph() procedure.
When a clone node is made using apoc.refactor.cloneSubgraph() inside a transaction which is rolled back (manually or automatically), the clone survives the rollback, while other changes made inside the transaction do not. The effect is to break ACID compliance.

Expected Behavior (Mandatory)

Clone nodes should vanish with the rest of the transaction changes on rollback.

Actual Behavior (Mandatory)

Clone nodes survive as orphans exactly as made out of cloneSubgraph(), but without other (subsequent) changes made to them during the transaction.

How to Reproduce the Problem

This Cypher illustrates the fault:

        CREATE  (rootA:Root2{name:'A'}),
        (rootB:Root2{name:'B'}),
        (n1:Node2{name:'node1', id:1}),
        (n2:Node2{name:'node2', id:2}),
        (n3:Node2{name:'node3', id:3}),
        (n4:Node2{name:'node4', id:4})
        CREATE (rootA)-[:LINK]->(n1)-[:LINK]->(n2)-[:LINK]->(n3)
        CREATE (rootB)-[:LINK]->(n4)
        WITH rootA, rootB
CALL apoc.path.subgraphAll(rootA, {relationshipFilter:'LINK>'})
YIELD nodes, relationships
CALL apoc.refactor.cloneSubgraph(
    nodes,
    [rel in relationships WHERE type(rel) = 'LINK']
)
YIELD input, output as clone, error     // this clone node survives(!)
SET clone.id = "clone".                        // however this change doesn't survive
RETURN 1/0                                        // rollback makes orphans

Steps (Mandatory)

  1. Issue the above Cypher query in an empty DB
  2. Check that the clone node survived: MATCH (n) RETURN n

Specifications (Mandatory)

Currently used versions

Versions

Community Edition

  • OS: macOS Ventura 13.6.4
  • Neo4j: 5.21.2
  • Neo4j-Apoc: 5.21.2
@jexp
Copy link
Member

jexp commented Nov 13, 2024

Yes it's kinda intentional, because the subgraph can be big the operation is batched.

See:

https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/4.4/core/src/main/java/apoc/refactor/GraphRefactoring.java#L283

@vga91 vga91 added the core-functionality Adding new procedure, function or signature to APOC core label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-functionality Adding new procedure, function or signature to APOC core
Projects
None yet
Development

No branches or pull requests

3 participants