Skip to content

fix(transaction): Only rollback if connection was acquired - #9051

Merged
sushantdhiman merged 4 commits into
sequelize:masterfrom
holm:pr/transaction_rollback
Mar 20, 2018
Merged

sushantdhiman merged 4 commits into
sequelize:masterfrom
holm:pr/transaction_rollback

Conversation

@holm

@holm holm commented Feb 14, 2018

Copy link
Copy Markdown
Contributor

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

This fixes #8087. Before a transaction was always attempted to be rolled back, even if the transaction had not started yet. This could happen when a connection could not be acquired, for whatever reason.

I don't think writing a test for this is worth the effort.

@sushantdhiman sushantdhiman left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its hard to verify this fix without a proper testcase

@holm

holm commented Feb 16, 2018

Copy link
Copy Markdown
Contributor Author

I guess we can try to make a testcase, but it will be very messy. We have to stub a failure in acquiring a connection and then check for unhandled rejections. I am not sure such a testcase will do much good, but happy to take suggestions on how to build a proper testcase.

@AlexeyKhristov

Copy link
Copy Markdown

Have same issue. This PR fixes it.
+1 to merge it.

@holm

holm commented Mar 7, 2018

Copy link
Copy Markdown
Contributor Author

We get this error from time to time, and it would be really helpful to have this merged.

@holm

holm commented Mar 14, 2018

Copy link
Copy Markdown
Contributor Author

It is getting a bit frustrating to have submitted PR's to fix issues, and they are just left to rot. Can we get this properly reviewed please`

@sushantdhiman

Copy link
Copy Markdown
Contributor

@holm Have some patience please. Its a large project, I have a job, I am working on v5, still reviewing and merging stuff almost on daily basis.

Thanks for debugging and fixing this. As I said before this PR is missing a test case, which I think is important and I am trying to eventually get back to this, but that will take some time.

@clncln1

clncln1 commented Mar 16, 2018

Copy link
Copy Markdown
Contributor

@sushantdhiman @holm

I also think this is a rather critical issue since it results in unhandled promise rejections at least under load. I have created a test case for this one that should clearly show the impact.
Let me know if you need changes to that one

test: add pool rejection test
@codecov

codecov Bot commented Mar 16, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #9051 into master will not change coverage.
The diff coverage is 100%.

@holm

holm commented Mar 16, 2018

Copy link
Copy Markdown
Contributor Author

Thanks, I merged your testcase into this PR

@itsmepetrov

Copy link
Copy Markdown

@sushantdhiman as I can see, @holm has already added testcase for that PR, do you have any plans to merge it?

@sushantdhiman

Copy link
Copy Markdown
Contributor

@itsmepetrov Yes, I'll verify and merge this fix tomorrow morning

@sushantdhiman sushantdhiman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix Verified!! LGTM

@sushantdhiman
sushantdhiman requested a review from a team March 20, 2018 04:53
@sushantdhiman
sushantdhiman merged commit a7e9e2b into sequelize:master Mar 20, 2018
@sushantdhiman

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 4.37.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unhandled rejection TypeError: Cannot read property 'query' of undefined

6 participants