question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Idle connections thrash when pool min > 0 (i.e. by default)

See original GitHub issue

I was going to raise this against generic-pool-redux, but I’m not sure if it’s not perhaps an issue with a missing config option here in knex.

The default minimum pool size in knex is 2, so by default 2 connections are kept active at all times. At the same time, there is an idle timeout set to 30 seconds in generic-pool-redux, which cleans away idle connections.

The result is that by default connections are opened and closed every 30 seconds whenever a client is idle. This isn’t much of an issue, until you start scaling the number of clients talking to a database. Then the thrashing LOGN & QUIT requests activating and deactivating idle connections starts blocking real requests from being able to access the database.

Setting min:0 stops the thrashing, but I don’t think this behaviour is correct, especially not as the default behaviour for the library.

Perhaps there is or should be a way to stop idle connections from being cleaned away when there is a min > 0, or perhaps the default min should be 0?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
xxxcommented, Jun 1, 2017

I think this has become an issue again with the switch to generic-pool for pooling as of 0.12.0. We definitely see it with 0.12.9.

edit: We were able to resolve it by add refreshIdle: false to the config

0reactions
ErisDScommented, May 27, 2016

Ok cool, so the default changed - that’s a good start. I also went and read the pool2 docs and they say this:

idleTimeout

An integer, in milliseconds, to specify how long a resource must be idle before it may be disposed of. Resources are periodically checked (see syncInterval below) for idleness, and idle resources are disposed of unless they would bring the pool below the configured min value.

This sounds like the logic in pool2 will result in much better behaviour. Thanks for the info!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Idle connections thrash when pool min > 0 (ie by default) #503
The result is that by default connections are opened and closed every 30 seconds whenever a client is idle. This isn't much of...
Read more >
How to close idle connections in PostgreSQL automatically?
Now click on the newly created parameter group and search 'idle'. The default value for 'idle_in_transaction_session_timeout' is set to 24 hours ...
Read more >
server: Server tag configuration - Caucho Resin
In Resin, a number of threads wait to accept a new connection and then handle the request. <accept-thread-min> specifies the minimum number of...
Read more >
PoolingOptions (DataStax Java Driver for Apache Cassandra
Sets the timeout before an idle connection is removed. The order of magnitude should be a few minutes (the default is 120 seconds)....
Read more >
What is connection pooling, and why should you care
A typical database connection Why pool database connections? ... resources (although it's worth noting that idle connections in CockroachDB ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found