Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SequlizeJS connection get timeout frequently

We have a project backend running on NodeJS / expressJS / SequilizeJS as a RESTapi. That RESTapi connceted to a VueJS SPA.

Only 5 people use this system. Most of the operations are transactions.

We get an error

SequelizeConnectionAcquireTimeoutError: Operation timeout

This is our config object.

const sequelize = new Sequelize(
  config.database,
  config.username,
  config.password,
  {
    host: config.host,
    dialect: "mysql",
    pool: {
      max: 20,
      min: 0,
      acquire: 30000,
      idle: 10000
    }
  }
);

We are certain that our server's memory is not the issue. Because only 5 percent is used.

Where does this error comes from?

like image 651
Pathum Kalhan Avatar asked Jun 27 '19 06:06

Pathum Kalhan


People also ask

How to set query timeout in Sequelize V5?

If someone stumbles here looking for Postgres specific config (i.e. node-postgres) for query timeout, it looks like this in sequelize v5: dialectOptions: { statement_timeout: 1000, idle_in_transaction_session_timeout: 5000 } This will set statement_timeout to 1s and idle_in_transaction_session_timeout to 5s.

What happens when you set a query timeout?

The query timeout error will be given back to the application for handling. Setting a query timeout will not resolve why the queries are taking a long time to complete, but it will timeout any long queries so the application can handle the exception and free up that connection.

Why do connections stay open for a long period of time?

Common Reasons Why Connections Stay Open for a Long Period of Time in WebSphere Application Server When you are monitoring connection pool performance, you may occasionally notice that connections are staying open for long periods of time. This behavior can have many different causes and can lead to issues like the connection pool maxing out.

What is the use of get use get use close pattern?

When the get/use/get/use/get/use……/ close pattern is used, the application does not call close until the very last request is completed. That means that the rest of the connections will remain open in the pool with a ‘Connections being held’ or ‘Handle count’ value of 1 until that very last request completes.


1 Answers

Change acquire to 60000, It will resolve otherwise you need to recheck that particular query where it is coming. acquire: 60000

like image 175
Vivek Kapoor Avatar answered Oct 20 '22 10:10

Vivek Kapoor