Repository navigation
Closed
Description
What you are doing?
I have a script which parses XML and loads them into a database. This script previously worked with Postgres SQL. I must switch to MSSQL. I have the following db connection settings:
// code here
{ "username":username,
"password":"password,
"database":database,
"host":host,
"port": "post,
"dialect":"mssql",
"connectionTimeout": 0,
"pool":{
"max": 1,
"min": 1,
"idle": 200000,
"acquire": 200000
},
"retry":{"max": 3},
"logging": false,
"dialectOptions": {
"requestTimeout": 0,
},
"options":{
"port": port
}
}What do you expect to happen?
I wanted the data to load into the database.
What is actually happening?
The records load for approximately 4 minutes. Then i get the following error:
{ TimeoutError: ResourceRequest timed out
at ResourceRequest._fireTimeout (/home/jcook/riqi_provider_directory/node_modules/sequelize/node_modules/generic-pool/lib/ResourceRequest.js:59:17)
at Timeout.bound [as _onTimeout] (/home/jcook/riqi_provider_directory/node_modules/sequelize/node_modules/generic-pool/lib/ResourceRequest.js:8:15)
at ontimeout (timers.js:469:11)
at tryOnTimeout (timers.js:304:5)
at Timer.listOnTimeout (timers.js:264:5) name: 'TimeoutError' }Some data continues to load, but it looks like not all of my records are inserted into the database.
Dialect: mssql
Database version: 2008
Sequelize version: 4.1.0
Reacted by 木士羽, Alex Hokanson, spencercwood, Hieu, Le, wendell-zhang, Siddharth Doshi, Orest Prystayko, Nick Laros, Jaroslavs Kuprijanovs, Nate and 10 more
Reacted by Nontachai Tantiponsawas and Dimitri DO BAIRRO
Metadata
Metadata
Assignees
Labels
No labels
Activity
jeremyklein commentedon Aug 17, 2017
Increasing the max pool size allowed the data to be loaded. I would prefer not to need 100 connections to the database to load this data.
xdamman commentedon Sep 5, 2017
I have the same issue but increasing the max pool size didn't help. I'm using the very latest version (4.8 and cli 2.8.0)
jeremyklein commentedon Sep 5, 2017
Which verson of Tedious are you using?
xdamman commentedon Sep 6, 2017
@jeremyklein tedious? Not using it / never heard of it. Using Postgres 9.6 btw
xdamman commentedon Sep 8, 2017
Still having the same issue with sequelize 4.8.2 and sequelize cli 3.0.0 (and Postgres 9.6 on MacOSX)
xdamman commentedon Sep 8, 2017
Here is how I solved it:
I've added
{ concurrency: 10 }toPromise.map(array, Promise, { concurrency: 10 });idris commentedon Jan 15, 2018
I can't seem to get rid of the
ResourceRequest timed outerrors. I've tried various settings. Here are my currentpoolsettings:I'm using RDS Postgres. If it's exceeding the 40 second acquire time I set, does that essentially mean that all 5 connections are busy for 40 seconds?
Celadora commentedon Jan 24, 2018
We are experiencing this problem across all services now (that had previously been working fine for over a year) that use Sequelize to connect to a Digital Ocean droplet (where the MySQL database is located). It seems like the more the service connects to the database, the sooner the error appears. After it appears the services must be restarted.
idris commentedon Jan 24, 2018
@Celadora if I understand this issue correctly, this is just a matter of tweaking the pool settings. In v2 (not sure about v3), there was no acquire timeout, so if all connections in the pool were busy, your app would just wait forever until a connection freed up. This was obviously not ideal. Although it did not throw an error, it was dangerous.
In v4, you need to decide on timeouts that make sense for your app. If you want the old behavior, I think the closest thing would be to increase
acquireto something ridiculously high like1000000. Obviously, that's silly. My real recommendation would be to increase the poolmaxto something higher (I used30), and setacquireto something reasonable for your app.I think the main root cause for this whole issue is long-running queries. If you have a pool max of 5 connections, and you have 5 concurrent queries going, with each query taking 30 seconds, your acquire is going to have to wait at least 30 seconds to get a connection. Those queries can also queue up a bit, thereby exacerbating the problem.
Hope that helps, and I hope everything I said is accurate. Anyone, please correct me if I'm wrong on any of that.
Celadora commentedon Apr 15, 2018
@idris Thank you very much! Your advice corrected the issue.
mkaufmaner commentedon Jul 2, 2019
For those of you still using v4 of Sequelize, this problem may have been fixed by v4.44.1.
See PR: #11140
See Issue: #11139
ndangles commentedon Aug 29, 2020
My issue was that I was using unmanaged transactions which require manual calls of commit and rollback and I was forgetting to call rollback in the catch block of my try/catch after throwing an error resulting in a hanging transaction which eventually returned
SequelizeConnectionAcquireTimeoutError. Stripped down example below.Faulty Code
Correct Code
miguelHM63 commentedon Jul 12, 2022
@ndangles can you send this error to your client? because that error would jump to the catch block, something similar happened to me and I had to handle the errors of the try block, in the catch block