node-sqlserver-v8 icon indicating copy to clipboard operation
node-sqlserver-v8 copied to clipboard

Pool always grows to ceiling and doesn't use idle connections

Open bruceferguson2 opened this issue 1 year ago • 2 comments

I noticed while watching my DB and also watching debug events:

  1. I set floor to 3 and ceiling to 100 to account for very bursty activity.
  2. I send a query to the pool (pool.promises.query) and it immediately ramps up to 100 connections INSTEAD of just using the three that are idle due to the floor setting.
  3. It appears that the grow() function ALWAYS ramps up to ceiling when any query comes in.

It seems like the grow function should have something like:

if (idle.length > 0) { return; }

let needed = "some-logic-for-computing-needed connections"

Then use "needed" in the for loop to add new connections to the pool.

Perhaps the logic could be parameterized with something like: percentageToAdd minToAdd maxtoAdd

Just thinking off the top of my head.

bruceferguson2 avatar Jul 05 '24 13:07 bruceferguson2

Hello I am facing this issue too. Do we have any update on this issue ? This seems to be critical.

Ashwinkumar-R avatar Sep 25 '24 08:09 Ashwinkumar-R

it is very unlikely this will be changed, the library is now in maintenance - I will try and build latest version binaries to keep up to date with new node releases, but i do not have anything like the time anymore to go beyond that.

if anyone wishes to take it on, please fork and continue.

TimelordUK avatar Oct 06 '24 15:10 TimelordUK

there has been some growth strategies added in latest version - efficient should behave better where we only grow if there are no idle connections

https://github.com/TimelordUK/node-sqlserver-v8/blob/master/test/pool-efficient-strategy.test.js

TimelordUK avatar Jul 20 '25 12:07 TimelordUK