coopernurse / node-pool

Generic resource pooling for node.js
2.38k stars 259 forks source link

More connections being open that configured #169

Closed b2rsp closed 7 years ago

b2rsp commented 7 years ago

Hi,

I am using Knex with bookshelf: "knex": "^0.12.6", "bookshelf": "^0.10.2", "mssql": "^3.3.0", "generic-pool": "^2.4.2"

And i have this configuration

 database: {
    acquireConnectionTimeout: 40000,
    client: 'mssql',
    connection: {
        host: '-----',
        port: 1433,
        database: '----'
    },
    pool: {
      min: 0,
      max: 25,
      idleTimeout: 30000,
      syncInterval: 5000
    }
  }

And this is the code i initialize the knex:

import config from '~/config';

export const knex = require('knex')(config.database);
export const bookshelf = require('bookshelf')(knex);

bookshelf.plugin('pagination');

export default bookshelf;

The issue is i have a listener/loop to read AWS SQS and there some times i have spike in terms of connections to the MSSQL beyond the max configured (25). I get something 55-70.

And i was wondering if any guys know any idea of what is happening ?

sandfox commented 7 years ago

@b2rsp - where are you getting the "55-70" figure from? is that being reported from MSSQL? Off the top of my head I can foresee there be a few scenarios where what you are seeing can happen.

Unfortunately I'm not very familiar with how knex uses generic-pool, and they may have a better idea?

Do you have any logs or anything else?

b2rsp commented 7 years ago

@sandfox Thanks very much for the quick response. I already discovered the issue and there some misunderstanding by reading the TCP connections with the TIME_WAIT, so there weren't any issue with the pool after all. Still thanks very much for the response and good work :)

sandfox commented 7 years ago

I'm glad you were able to get to the bottom of it, and thanks for the kind words!