不要怂,就是干,撸起袖子干!

Commit 4660d0c1 by Skylar Graika Committed by Sushant

(fix): connection manager evict stale connections (#7924)

* Eviction config in connection-manager.js 

Added configuration property `evictionRunIntervalMillis` to node-pool instantiation to allow evictions to run against stale connections in the pool. The default value is set to 0 which prevents evictions all together. The added configuration will cause evictions to run every 60 seconds. The setting has been exposed in the Sequelize configuration options.

* Update default pool options in usage.md

Corrected the existing default pooling options in `usage.md` and added new option for evict which controls the interval in which evictions run.

* Added evictionTimeoutMillis to remaining areas

Adding `evictionTimeoutMillis` to remaining configuration areas within `connection-manager.js`

* Adding documentation for `options.pool.evict`

Updating the comment which documents the configuration parameters available when constructing a new _Sequelize_ object.

* Change "between" -> "for" 

Updating the grammar for simplify the understanding of this option.
1 parent 05f3c6d8
......@@ -149,9 +149,12 @@ Sequelize uses a pool to manage connections to your replicas. The default option
```js
{
max: 10,
max: 5,
min: 0,
idle: 1000
idle: 10000,
acquire: 10000,
evict: 60000,
handleDisconnects: true
}
```
......
......@@ -13,6 +13,7 @@ const defaultPoolingConfig = {
min: 0,
idle: 10000,
acquire: 10000,
evict: 60000,
handleDisconnects: true
};
......@@ -111,7 +112,8 @@ class ConnectionManager {
testOnBorrow: true,
autostart: false,
acquireTimeoutMillis: config.pool.acquire,
idleTimeoutMillis: config.pool.idle
idleTimeoutMillis: config.pool.idle,
evictionRunIntervalMillis: config.pool.evict
});
this.pool.on('factoryCreateError', error => {
......@@ -197,7 +199,8 @@ class ConnectionManager {
testOnBorrow: true,
autostart: false,
acquireTimeoutMillis: config.pool.acquire,
idleTimeoutMillis: config.pool.idle
idleTimeoutMillis: config.pool.idle,
evictionRunIntervalMillis: config.pool.evict
}),
write: Pooling.createPool({
create: () => new Promise(resolve => {
......@@ -223,7 +226,8 @@ class ConnectionManager {
testOnBorrow: true,
autostart: false,
acquireTimeoutMillis: config.pool.acquire,
idleTimeoutMillis: config.pool.idle
idleTimeoutMillis: config.pool.idle,
evictionRunIntervalMillis: config.pool.evict
})
};
......
......@@ -85,6 +85,7 @@ class Sequelize {
* @param {Integer} [options.pool.idle] The maximum time, in milliseconds, that a connection can be idle before being released
* @param {Integer} [options.pool.acquire] The maximum time, in milliseconds, that pool will try to get connection before throwing error
* @param {Function} [options.pool.validate] A function that validates a connection. Called with client. The default function checks that client is an object, and that its state is not disconnected
* @param {Integer} [options.pool.evict] The time interval, in milliseconds, for evicting stale connections. The default value is 0, which disables this feature.
* @param {Boolean} [options.quoteIdentifiers=true] Set to `false` to make table names and attributes case-insensitive on Postgres and skip double quoting of them. WARNING: Setting this to false may expose vulnerabilities and is not reccomended!
* @param {String} [options.transactionType='DEFERRED'] Set the default transaction type. See `Sequelize.Transaction.TYPES` for possible options. Sqlite only.
* @param {String} [options.isolationLevel] Set the default transaction isolation level. See `Sequelize.Transaction.ISOLATION_LEVELS` for possible options.
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!