-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ResourceRequest timed out - connection not reestablished after db restarted #8014
Comments
I go through the same situation. I have not found a solution yet ;( |
@sushantdhiman #8330 does not fix this issue. Still experiencing the Could you please re-open this ticket until #8022 is merged? |
@smithdalec Can you provide me a test case to test with, something like #7884 (comment) |
@sushantdhiman I can use the test case as described in the initial comment and reproduce the issue using the linked Docker container with MSSQL. > node db-test.js
Executing (default): SELECT 'connection is successful'
[ { '': 'connection is successful' } ]
Executing (default): SELECT 'connection is successful'
{ SequelizeDatabaseError: Connection closed before request completed.
at Query.formatError (node_modules/sequelize/lib/dialects/mssql/query.js:322:12)
at Request.connection.lib.Request [as userCallback] (node_modules/sequelize/lib/dialects/mssql/query.js:107:25)
at Request._this.callback (node_modules/tedious/lib/request.js:47:27)
at Connection.cleanupConnection (node_modules/tedious/lib/connection.js:324:24)
at Connection.enter (node_modules/tedious/lib/connection.js:1440:19)
at Connection.transitionTo (node_modules/tedious/lib/connection.js:676:33)
at Connection.socketEnd (node_modules/tedious/lib/connection.js:719:19)
at emitNone (events.js:91:20)
at Socket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
name: 'SequelizeDatabaseError',
parent:
{ RequestError: Connection closed before request completed.
at RequestError (node_modules/tedious/lib/errors.js:34:12)
at Connection.cleanupConnection (node_modules/tedious/lib/connection.js:323:21)
at Connection.enter (node_modules/tedious/lib/connection.js:1440:19)
at Connection.transitionTo (node_modules/tedious/lib/connection.js:676:33)
at Connection.socketEnd (node_modules/tedious/lib/connection.js:719:19)
at emitNone (events.js:91:20)
at Socket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
message: 'Connection closed before request completed.',
code: 'ECLOSE',
sql: 'SELECT \'connection is successful\'' },
original:
{ RequestError: Connection closed before request completed.
at RequestError (node_modules/tedious/lib/errors.js:34:12)
at Connection.cleanupConnection (node_modules/tedious/lib/connection.js:323:21)
at Connection.enter (node_modules/tedious/lib/connection.js:1440:19)
at Connection.transitionTo (node_modules/tedious/lib/connection.js:676:33)
at Connection.socketEnd (node_modules/tedious/lib/connection.js:719:19)
at emitNone (events.js:91:20)
at Socket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
message: 'Connection closed before request completed.',
code: 'ECLOSE',
sql: 'SELECT \'connection is successful\'' },
sql: 'SELECT \'connection is successful\'' }
{ TimeoutError: ResourceRequest timed out
at ResourceRequest._fireTimeout (node_modules/generic-pool/lib/ResourceRequest.js:58:17)
at Timeout.bound (node_modules/generic-pool/lib/ResourceRequest.js:8:15)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5) name: 'TimeoutError' }
{ TimeoutError: ResourceRequest timed out
at ResourceRequest._fireTimeout (node_modules/generic-pool/lib/ResourceRequest.js:58:17)
at Timeout.bound (node_modules/generic-pool/lib/ResourceRequest.js:8:15)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5) name: 'TimeoutError' }
{ TimeoutError: ResourceRequest timed out
at ResourceRequest._fireTimeout (node_modules/generic-pool/lib/ResourceRequest.js:58:17)
at Timeout.bound (node_modules/generic-pool/lib/ResourceRequest.js:8:15)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5) name: 'TimeoutError' } You can see that, while the db server is originally running, the Here's my output with node db-test.js
Executing (default): SELECT 'connection is successful'
[ { '': 'connection is successful' } ]
Executing (default): SELECT 'connection is successful'
[ { '': 'connection is successful' } ]
{ SequelizeConnectionError
at Connection.connection.on (node_modules/sequelize/lib/dialects/mssql/connection-manager.js:77:18)
at emitNone (events.js:86:13)
at Connection.emit (events.js:185:7)
at Connection.cleanupConnection (node_modules/tedious/lib/connection.js:318:16)
at Connection.enter (node_modules/tedious/lib/connection.js:1440:19)
at Connection.transitionTo (node_modules/tedious/lib/connection.js:676:33)
at Connection.socketEnd (node_modules/tedious/lib/connection.js:719:19)
at emitNone (events.js:91:20)
at Socket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
name: 'SequelizeConnectionError',
message: undefined,
parent: 'Error connecting to the database',
original: 'Error connecting to the database' }
{ TimeoutError: ResourceRequest timed out
at ResourceRequest._fireTimeout (node_modules/generic-pool/lib/ResourceRequest.js:58:17)
at Timeout.bound (node_modules/generic-pool/lib/ResourceRequest.js:8:15)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5) name: 'TimeoutError' }
{ SequelizeConnectionError
at Connection.connection.on (node_modules/sequelize/lib/dialects/mssql/connection-manager.js:77:18)
at emitNone (events.js:86:13)
at Connection.emit (events.js:185:7)
at Connection.cleanupConnection (node_modules/tedious/lib/connection.js:318:16)
at Connection.enter (node_modules/tedious/lib/connection.js:1440:19)
at Connection.transitionTo (node_modules/tedious/lib/connection.js:676:33)
at Connection.socketEnd (node_modules/tedious/lib/connection.js:719:19)
at emitNone (events.js:91:20)
at Socket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
name: 'SequelizeConnectionError',
message: undefined,
parent: 'Error connecting to the database',
original: 'Error connecting to the database' }
Executing (default): SELECT 'connection is successful'
[ { '': 'connection is successful' } ]
Executing (default): SELECT 'connection is successful'
[ { '': 'connection is successful' } ]
Executing (default): SELECT 'connection is successful'
[ { '': 'connection is successful' } ] You can see here that the connection is properly re-established after the db server is restarted Hope that helps 👍 |
I am also experiencing this problem. I think bad connections are not getting removed from the pool and the pool is filling up. I get similar problems after a couple days in production. |
Hi everyone, Would be great to have a solution. |
I'm dealing with this same issue as @joe-angell . App runs along flawlessly for a two to three days and then all of a sudden there are resources in the pool that are never being removed and If there is something I can write in the |
@ansongoldade yeah even with my own custom improved validation function i'm still getting timeouts from failing to acquire the connection. 8 events on one machine we deployed the fix to in the last 2 days out of a couple million requests... But it seems to recover afterwards now. So probably an uncaught exception somewhere that is not getting to stdout is my guess. See this for the extreme validation function... note that connection.query will be null if the db goes down for any length of time. |
Updated to 4.22.5 but still run into the issue ResourceRequest timed out sometimes. My pool config dialect: 'mssql', Looking for advise :( |
My colleague has made some progress identifying a possibly related error: #8756 |
I believe that PR is fixing that issue. |
For anyone else who needs a quick reference, Although the version is a little outdated - e.g. there is no |
@sushantdhiman I'm still able to reproduce this error with |
@smithdalec @sushantdhiman Same for me, I am still having the same issue. |
@cladjules @smithdalec How you are using that fix?, have you actually set proper |
Hi @sushantdhiman I have tried different configuration,
I have also tried to configuration mentioned in the PR. Thanks. |
I can still reproduce this issue, will investigate |
What you are doing?
We're running into an issue where Sequelize will not reconnect to the database after the database is stopped and started again. If you want, you can try hosting a local mssql database using this tutorial and running the following code, and following the steps I provide below:
https://medium.com/@reverentgeek/sql-server-running-on-a-mac-3efafda48861
Steps after code is running and mssql container is running:
I'm pretty sure this should reject, but I'm not too sure: https://github.com/sequelize/sequelize/blob/master/lib/dialects/abstract/connection-manager.js#L98
What do you expect to happen?
Sequelize to reconnect and have queries work as normal.
What is actually happening?
Sequelize fails to reconnect the created pool resource.
Dialect: mssql, but probably all
Database version: XXX
Sequelize version: 4.4.2
The text was updated successfully, but these errors were encountered: