Skip to content

fix(connection): fixes mssql reconnect bug (duplicate of pr#8022) - #8815

Closed
iamjoyce wants to merge 1 commit into
sequelize:masterfrom
iamjoyce:bug/pr_8022
Closed

iamjoyce wants to merge 1 commit into
sequelize:masterfrom
iamjoyce:bug/pr_8022

Conversation

@iamjoyce

@iamjoyce iamjoyce commented Dec 26, 2017 •

Copy link
Copy Markdown

-- Edited on 18 Jan --

Let me know if you are interested to take this over, I will transfer the repo to your name

Initially I thought the only thing stopping the PR from being merged was the outdated master branch codes, hence I created the PR. I don't think I understand the codes well enough to give my input on how this issue should be fixed, so it will probably be better for someone else to continue this.

-- End Edit --

Pull Request check-list

  • 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

Purpose: Fixes MSSQL reconnect bug

Related Issue: #8014

Referenced from PR #8022

  • Credits entirely goes to @codyseibert
  • Created a new PR to make test case fixes easier
  • Updated branch to latest master branch 68d729d

@codecov

codecov Bot commented Dec 26, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #8815 into master will decrease coverage by <.01%.
The diff coverage is 94.44%.

@iamjoyce iamjoyce changed the title fix(connection): duplicate of pr#8022 fix(connection): fixes mssql reconnect bug (duplicate of pr#8022) Dec 26, 2017
Added connection retry to pooling configuration

Closes #8014
@iamjoyce

iamjoyce commented Dec 26, 2017 •

Copy link
Copy Markdown
Author

According to comment by @eseliger, I assume the test case provided is good enough, even though codecov says otherwise.

Please let me know if other test cases are necessary, examples will be appreciated. If not, it will be nice if we can merge this and get this on the next release.

@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.

Sorry for not taking time to review original PR. I have some comments

  1. This is just a brute force attempt, 1 try didnt worked lets try 5 more time
  2. Real issue is still remains uncovered and there is no good testcase for that (is there?)
  3. We can solve issue partially by returning a specialised timeout error SequelizeTimeoutError instead of "Resource Request TImeout"

this.pool = Pooling.createPool({
create: () => this._connect(config).catch(err => err),
create: () =>
retry(() => this._connect(config), {

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.

This is not fixing any issue, we are just retrying 5 more time. Real issue is still there

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I agree, when I was reading the codes that's what I thought as well. However, the weird thing is, a few others mentioned that that PR managed to solve their timeout issue.


return promise.then(() => {
return this.pool.acquire(options.priority, options.type, options.useMaster)
return new Promise((resolve, reject) => {

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.

May be old code but this is no longer required, we now return error to pool and handle that when resolving connection


connection.on('end', () => {
if (!connected) {
reject(new sequelizeErrors.ConnectionError('Error connecting to the database'));

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.

This is something acceptable, but this is not the actual error. Its a timeout, which is already returned by pooling library? (It should be, as Resource Request Timeout). May be we should return a SequelizeTimeoutError or something

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I am happy to help to fix that ASAP.
Can I, somehow, edit the PR to do those changes?

Thanks :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@cladjules do you think it's possible for me to just transfer the entire repo to your name?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@iamjoyce let me try to do a new PR and copy your code manually, there is not much to change. Thanks.

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.

@cladjules did you get a chance to look at this? Instead of copying the code you should be able to branch off @iamjoyce branch and then do a PR onto @iamjoyce or open a new PR directly on here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I will try to have a look this weekend. But quite busy. I will see what I can do and how I can reproduce...

@aviranco

Copy link
Copy Markdown

Is this fix also relevant for postgreSQL?

@depoulo

depoulo commented Jan 18, 2018

Copy link
Copy Markdown

For me, reconnecting (MariaDB) now works with the official v4.31.2.
So long, and good luck with this PR 👋

@sushantdhiman

Copy link
Copy Markdown
Contributor

Fixed by #8991

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.

6 participants