# Rollback problem

**URL:** <https://community.neo4j.com/t/rollback-problem/67122>\
**Category:** Java\
**Created:** [March 31, 2024, 6:54pm UTC](https://community.neo4j.com/t/rollback-problem/67122 "2024-03-31T18:54:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![xar.zax](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/xar.zax/32/32533_2.png) [@xar.zax](https://community.neo4j.com/u/xar.zax)\
**Post date:** [March 31, 2024, 6:54pm UTC](https://community.neo4j.com/t/rollback-problem/67122/1 "2024-03-31T18:54:06Z")

</div>

Hello guys,

```auto
public void rollbackTest()
    {
        final Driver driver = ...;
        final String cypherQuery = "CALL gds.beta.pipeline.linkPrediction.create('pipe');";
        try (final Session session = driver.session())
        {
            final Transaction transaction = session.beginTransaction();
            transaction.run(cypherQuery);
            transaction.rollback();
        }
        catch (final Exception e)
        {
            e.printStackTrace();
        }
    }

```

after executing this code the transaction doesn't rollback, when i manually execute

```auto
CALL gds.pipeline.list

```

the pipeline is added on the catalog. Does anybody have a clue?

---

<div class="post-metadata">

**Author:** ![xar.zax](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/xar.zax/32/32533_2.png) [@xar.zax](https://community.neo4j.com/u/xar.zax)\
**Post date:** [April 3, 2024, 9:30am UTC](https://community.neo4j.com/t/rollback-problem/67122/2 "2024-04-03T09:30:48Z")

</div>

Bringing up my post.

---

<div class="post-metadata">

**Author:** ![florent\_biville](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/florent_biville/32/14205_2.png) [@florent\_biville](https://community.neo4j.com/u/florent_biville)\
**Post date:** [April 3, 2024, 9:46am UTC](https://community.neo4j.com/t/rollback-problem/67122/3 "2024-04-03T09:46:45Z")

</div>

Another way to rollback is to auto-close the transaction without committing it:

```auto
public void rollbackTest()
    {
        final Driver driver = ...;
        final String cypherQuery = "CALL gds.beta.pipeline.linkPrediction.create('pipe');";
        try (final Session session = driver.session();
             final Transaction transaction = session.beginTransaction())
        {
            
            transaction.run(cypherQuery);
        }
        catch (final Exception e)
        {
            e.printStackTrace();
        }
    }

```

---

<div class="post-metadata">

**Author:** ![xar.zax](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/xar.zax/32/32533_2.png) [@xar.zax](https://community.neo4j.com/u/xar.zax)\
**Post date:** [April 3, 2024, 10:27am UTC](https://community.neo4j.com/t/rollback-problem/67122/4 "2024-04-03T10:27:51Z")

</div>

Thanks for the reply, the output is still the same. Seems like there is no rollback for graph algorithms.

---

<div class="post-metadata">

**Author:** ![florent\_biville](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/florent_biville/32/14205_2.png) [@florent\_biville](https://community.neo4j.com/u/florent_biville)\
**Post date:** [April 3, 2024, 10:39am UTC](https://community.neo4j.com/t/rollback-problem/67122/5 "2024-04-03T10:39:03Z")

</div>

Ah yes, sorry. It depends on what the procedure is doing.  
It may spawn its own transaction, for which you will indeed have no control.

---

<div class="post-metadata">

**Author:** ![gerrit.meier](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/gerrit.meier/32/27374_2.png) [@gerrit.meier](https://community.neo4j.com/u/gerrit.meier)\
**Post date:** [April 4, 2024, 4:14am UTC](https://community.neo4j.com/t/rollback-problem/67122/6 "2024-04-04T04:14:14Z")

</div>

The procedure in question writes directly into a static map when invoked. There is no transactional interaction with the database itself.  
Using procedures that interacts with the database, using the ongoing transaction, will respect the rollback.

If you're ok with it, this question can/should be moved into the GDS sub-forum.
