[BUG] Connection pool grows correctly but never shrinks back
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, node.js
- Domain
- database
Research direction
Start with the pool options and lifecycle documentation in README.md, then reproduce the issue using pool.query() and pool.connect() with shrink: true. Check whether the documented behavior matches the observed pool.poolSize after load; done means either deterministic shrinking works or the behavior and cleanup controls are clearly documented.
Written by the indexing model from the issue text.
Description
Describe your system
odbcPackage Version: 2.4.8- ODBC Driver: IBM DB2 ODBC DRIVER
- Database Name: DB2
- Database OS: IBM i (AS/400)
- Node.js Version: 18.17.1
- Node.js OS: IBM i
Describe the bug
When using the built-in connection pool with shrink: true, the pool grows beyond initialSize under load but does not shrink back once the load is gone. After all queries have completed and all connections have been released, pool.poolSize remains permanently greater than initialSize, even after a long idle period.
This behavior occurs both when using pool.query() and when explicitly acquiring and releasing connections using pool.connect() and connection.close().
Expected behavior
With shrink: true, once all connections are released and the system becomes idle, the pool should eventually shrink back to initialSize, or at least have a documented, deterministic behavior regarding when or if shrinking occurs.
To Reproduce
- Create a pool with the following options:
const pool = await odbc.pool({ connectionString, initialSize: 2, incrementSize: 1, maxSize: 20, shrink: true }); - Run multiple queries in parallel to force the pool to grow
await Promise.all(
Array.from({ length: 10 }, () =>
pool.query("SELECT 1")
)
);
#or using explicit connections:
const conn = await pool.connect();
await conn.query("SELECT 1");
await conn.close();
- Wait until all queries have completed.
- Log pool.poolSize
Additional context
Calling connection.close() seems to only return the connection to the pool and does not close the actual database connection. There does not appear to be a documented idle timeout or automatic cleanup of extra connections. As a result, once the pool grows beyond initialSize, it stays larger even when the application is idle. This makes it hard to control the total number of open database connections.
Is this behavior expected by design? If so, it would be helpful to clarify this in the documentation or provide a deterministic way to shrink or evict idle connections.
- Dominant language
- JavaScript
- Stars
- 158
- Forks
- 92
- Avg merge
- 4d 19h
- Merged PRs (30d)
- 5
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from IBM/node-odbc
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
security
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
[Bug] Sybase ASE: Encoding issue (works in msnodesqlv8, fails in node-odbc with \x1A artifacts)Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 28/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
[quality] useFocusTrap's Shift+Tab wrap and non-Tab/non-Escape key arms are never driven end to endPossibly taken @hivecommons-hive claimed this today. Openagent/quality hive/covered-by-pr hive/hosted-available-lke648397-260827-5n31 quality testing
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
agentic-workflows
Difficulty 1/5 Under an hour Newbie friendliness 85/100
githubnext/gh-aw-workshop#4220 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
JuliusBrussee/caveman#1189 ·
Maintainers usually reply within 1 day
-
priority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OpenHands/extensions#738 ·
Maintainers usually reply within 1 day