Skip to content

Nested service usage with transaction hooks at both of them? #118

Closed

Description

@RobIsHere

I think from a glance at the source code, that nested service calls where both the calling and the called service use the same transaction don't work?

At the moment it would cause nested transactions to run. E.g. MariaDB would COMMIT and start a new transaction. SQL Server would start a nested transaction.

https://mariadb.com/kb/en/library/sql-statements-that-cause-an-implicit-commit/

Activity

  1. RobIsHere commented on Sep 16, 2017

    @RobIsHere
    Author

    A reference counting mechanism could solve this in a way that only the outer transition is ever considered. This behavior could be added to the docs.

    At start:
    if no params.transaction:
    start it
    set params.transaction. refCounter = 0
    else
    params.transaction. refCounter++

    At end:
    if (params.transaction. refCounter == 0)
    commit
    else
    params.transaction. refCounter--

    At rollback:
    Nothing to change because the error hook cancels further hook and service processing

    I can make a PR if you are open for this solution?

  2. RobIsHere commented on Sep 25, 2017

    @RobIsHere
    Author

    transaction.end() in nested service call throws an error at the outer transaction.end()
    Cannot read property 'rollback' of null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions