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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed nested transactions #1226

Merged
merged 5 commits into from Mar 7, 2016

Commits on Feb 24, 2016

  1. fix synchronizing sibling nested transactions

    Before, if we had parent transaction A, and two nested sibling transactions
    inside it: B1 & B2, knex would hang when you asked it to execute any kind of
    a database operation in the second child transaction.
    
    Also, it had a bad Promise.settle() call that would break in case the
    previous child transaction promise not resolve to an array, which typically
    (e.g. when calling trx.commit() on the passed transaction object or
    resolving the transaction promise with no value) it would not.
    jurko-gospodnetic committed Feb 24, 2016
    Copy the full SHA
    d0836b8 View commit details
    Browse the repository at this point in the history

Commits on Feb 25, 2016

  1. Copy the full SHA
    675c684 View commit details
    Browse the repository at this point in the history
  2. simplify nested transaction _.queue variable initialization

    - removed an unnecessary `||` with an always `undefined` value
    - avoided waiting for an always resolved promise
    jurko-gospodnetic committed Feb 25, 2016
    Copy the full SHA
    4a0b49f View commit details
    Browse the repository at this point in the history
  3. simplify nested transaction - no need to track _childQueue

    The only thing each transaction needs to track is its last direct child
    transaction. That is then used to prevent each sibling transaction from
    starting (i.e. returning its connection) before its predecessor
    transaction completed.
    jurko-gospodnetic committed Feb 25, 2016
    Copy the full SHA
    e0e77df View commit details
    Browse the repository at this point in the history
  4. clean up sibling nested transaction tracking code

    - improved related comments
    - renamed `trx._queue` to `trx._previousSibling`
    - made code waiting for `trx._previousSibling`, instead of code initializing
      that promise, more explicit about waiting for the promise to be either
      resolved or rejected, i.e. `settled`/`completed`
    - made the code a bit more compact
    jurko-gospodnetic committed Feb 25, 2016
    Copy the full SHA
    f38f901 View commit details
    Browse the repository at this point in the history