Repository navigation
fix(connection): fixing mssql reconnect bug - #8022
codyseibert wants to merge 13 commits into
Conversation
There is currently a bug where if you restart a mssql database, sequelize will lock the pool resources. Once those are locked, all future requests to .acquire will throw a ResourceRequest timed out error. This commit wraps all the connect logic in a retry to prevent an inifite loop of trying to connect, and also watchins for an 'end' event in the mssql adapter to properly reject the promise if 'end' is sent before 'connect' is fired.
|
Anyone want to enlighten me as to what this "codecov/patch" failure is? I assume I need to have 95% coverage over the changes I added or something? |
| retry(() => this._connect(config), { | ||
| max: config.pool.connectRetries | ||
| }) | ||
| .then(resolve) |
There was a problem hiding this comment.
you can just return the promise, no need to wrap into another
| }) | ||
| .catch(e => { | ||
| this.poolError = e; | ||
| reject(e); |
| debug('connection acquired'); | ||
| resolve(connection); | ||
| }); | ||
|
|
|
@codyseibert What happened here? 🙈 |
|
@eseliger I don't know how to re-run the tests without closing and opening the PR. All these tests passed once before, but now they seem to be failing on arbitrary failures. |
|
You can amend on your current commit and then force push on your branch to retrigger this |
|
ok, I will try that for now on. Any clue what these coverage failures are? both continuous-integration/travis-ci/pr and continuous-integration/appveyor/pr passed in the past... |
|
You mean the codecov check? |
|
that, but more specifically the "continuous-integration/appveyor/pr" and "continuous-integration/travis-ci/pr" jobs fail randomly at times, but pass on other runs. They don't fail on individual unit / integration tests, but instead they seem to fail on removing coverage files or finding a database... appveyor |
|
Unfortunately, some times the tests fail due to timeouts and so on, for now, restarting them is the simplest solution, which is most easily done by just triggering another push as I wrote 2 messages ago |
|
@eseliger what do you recommend I run in npm to test and increase my codecov/patch coverage? I added a unit tests but it didn't seem to increase my codecov/patch report... |
|
You can see the uncovered lines directly here on codecov. I only see the error cases left. For me, that would be ok. |
|
@eseliger I'm not sure why it says line 77 is not covered. I wrote a unit tests to cover that specifically and it passes fine. Does codecov print for integration tests? |
|
@codyseibert we have tested this in our codebase and it solves our issue we are facing when the sequelize never reconnects to the database that was restarted. We have also tested both #7924 and #7922 None of those solve the @eseliger @codyseibert Can we help in any way to get this merged? |
|
Still broken. The same issue |
|
Possible ref.: coopernurse/node-pool#155 |
|
This fix solves the |
|
This fix solves the |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂 |
|
We are still seeing this error as well. Any update here? |
|
We've had a couple of problems that appear to be around this in production, the latest one just now where to recover the pool we've had to restart the server. It looks like the pool has almost completely drained apart from a couple of active connections. I know it seems like nagging at this point, but it's becoming a pressing issue. Can we please kick the can along on this patch again? Is there anything I can do to help it get across the line? |
|
We're also in the same boat. I'm not sure what else is needed to get this merged, but we're happy to lend a hand if there's something in particular this PR is missing. |
|
Is there a workaround for this while we are waiting for it to be merged? This is affecting our tracking system. It is growing fast and the dead connections are becoming more of an issue every day. |
|
This fix is also relevant for PostgreSQL or only for mysql? |
|
@ADumaine we're still at this state, yes, since August!
I even tried to rebase this once, but quickly gave up - I think this needs to be done by someone with more knowledge of Sequelizes ConnectionManager (@codyseibert cough cough) |
|
Has this PR been superseded by #8815? |
|
@guyellis looks like. Currently updating my project from using this PR to using the new one (and adopting all changes that happened to Sequelize in the past 6 months). The new PR fixes the issue for me. |
Pull Request check-list
Please make sure to review and check all of these items:
npm run testornpm run test-DIALECTpass with this change (including linting)?Description of change
Original Issue:
#8014
There is currently a bug where if you restart a mssql database,
sequelize will lock the pool resources. Once those are locked, all
future requests to .acquire will throw a ResourceRequest timed out
error. This commit wraps all the connect logic in a retry to prevent an
inifite loop of trying to connect, and also watchins for an 'end' event
in the mssql adapter to properly reject the promise if 'end' is sent
before 'connect' is fired.