-
Notifications
You must be signed in to change notification settings - Fork 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
Errors: Could not acquire a connection - Pool is closed #6991
Comments
@vishalbiradar Thanks for posting! We'll take a look as soon as possible. In the mean time, there are a few ways you can help speed things along:
Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly. For help with questions about Sails, click here. |
Hi, @vishalbiradar! I wonder if the database isn't configured to support that number of connections. If you reconfigure the database, we recommend reverting back to the default pool settings when testing it out. If that doesn't seem to fix the problem, would you provide a minimal repo that reproduces the behavior you're getting? Thanks! |
@rachaelshaw @MadisonHicks |
@rachaelshaw @MadisonHicks @rachaelshaw My questions are:
Below is the code snippet from config/datastores.js file const host = process.env.MYSQL_SERVER || 'localhost';
const user = process.env.MYSQL_USER || 'ddn_api';
const password = process.env.MYSQL_PASSWORD || 'password';
const database = process.env.MYSQL_DATABASE|| 'ddn_db_dev';
const port = process.env.MYSQL_PORT || 3306;
module.exports.datastores = {
default: {
adapter: require('sails-mysql'),
url: `mysql://${user}:${password}@${host}:${port}/${database}`
}
}; |
Hi @vishalbiradar, |
Hi @eashaw Yes the app is configured to run in production mode. We are using transactions and tried matching the default connectionLimit from the application to be compatible with maximum connections allowed to the database. We are observing that application gets stuck waiting forever for connections to be returned to the pool once the connection limit is hit.
But the above thread says we need to release connection explicitly if we are using getConnection(). We are using sails mysql-adapter which we hope handles opening the database connection and releases the connection back to the pool once the operation is completed (We hope that is not happening in our case at least). Could you please confirm this and help us resolving the issue to release the connections back to the pool? Not sure if this is similar to #6908 for machinepack-mysql? |
Hi @anudeepchandrat, the default settings work for most deployments of mysql. People using custom connections to their database might have to change their database's settings or change the number of connections in their Sails configuration. |
@eashaw Thank you for the information. We tried changing the number of connections in their Sails configuration using connectionLimit to be compatible with number of connections allowed from mysql database. Once the connectionLimit is reached from Sails we could see the requests are added to the queue and waiting forever for the free connections to be available. Also the Sails application is not able to serve any requests further until the server is restarted. Could you please let us know your thoughts on this? |
@anudeepchandrat, The try catch that you shared in the code above is already being handled by Sails, have you looked for any connection leaks in the transaction? |
@eashaw As mentioned above we have tried increasing the connectionLimit from Sails for now to handle increase in number of clients. Could you please let us know how to check for connection leaks in transactions? It would be great if you can share some snippet for handling transactions that would work for any number of calls rather than increasing the connectionLimit. |
Hey @anudeepchandrat, We suggest looking anywhere where you use |
@eashaw Thank you for the suggestions. We were able to resolve the issue following the references and approached mentioned at https://dev.paygoenergy.co/blog/2019-06-20-sailsjs-transactions-and-exits/ (Rule: never reference exits from within transaction). |
Node version: 10.13.0
Sails version (sails): 1.2.2
ORM hook version (sails-hook-orm): 2.1.1
Sockets hook version (sails-hook-sockets): 2.0.0
Grunt hook version (sails-hook-grunt): 4.0.0
DB adapter & version (e.g. [email protected]): [email protected]
I am trying to execute the 1000 API calls concurrently (using Artillery)but only 90-98 are successful and the remaining are failing. Also, the error is causing the server to stuck for some time.
I am getting below error:
Then I tried with pool options:
I am getting below error:
Some times I am getting an error:
The text was updated successfully, but these errors were encountered: