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

Nested transactions #295

Open
yarmash opened this issue Jan 6, 2018 · 2 comments
Open

Nested transactions #295

yarmash opened this issue Jan 6, 2018 · 2 comments
Labels
enhancement feature Describes a new feature

Comments

@yarmash
Copy link

yarmash commented Jan 6, 2018

Any reason we can't have nested transaction blocks? Currently this is a SystemError:

from config, db

config.DATABASE_URL = 'bolt://neo4j:password@localhost:7687'

with db.transaction:
    with db.transaction:
        pass

Output:

Traceback (most recent call last):
  File "test.py", line 7, in <module>
    with db.transaction:
  File "{..}/neomodel/util.py", line 127, in __enter__
    self.db.begin()
  File "{..}/neomodel/util.py", line 28, in wrapper
    return func(self, *args, **kwargs)
  File "{..}/neomodel/util.py", line 73, in begin
    raise SystemError("Transaction in progress")
SystemError: Transaction in progress
@dnarvaez27
Copy link

I might understand this solution to nested transactions, like having a read_transaction might conflict with an inner write one (here an exception must be thrown), but for an outter write_transactions (or a general transaction) with an inner read_transaction (or a general one) wouldn't the inner transaction reuse the outter one? Having write/read transactions is only relevant when having a neo4j cluster (as in my case).

Giving a peek at Neo4j High Performance, nested transactions are "part of the scope of the highest-level transaction", thus if an inner transaction fails, the outter one fails too. This behavior could be simulated having one transaction at all, the outter one.

@aanastasiou The solution of this issue brings code reusability, which is highly important for big projects. I find Neomodel a great solution among OGMs, but there has not been too much activity in this repo, even though Neo4j 4.0 brought new exciting features. If you need help with this or other issues I'll be happy to help in my free time.

@AntonLydike AntonLydike added the feature Describes a new feature label Sep 16, 2022
@Tijana37
Copy link

Is the feature implemented? Or did someone find a solution for nested transactions in Neomodel ?
@yarmash @dnarvaez27 @AntonLydike

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature Describes a new feature
Projects
None yet
Development

No branches or pull requests

5 participants