[BUG] No new connections being made on empty pool when maxSize is less than incrementSize
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript, node.js
調査の方向性
lib/Pool.js の211-212行目付近から始め、maxSize: 5、initialSize: 1、デフォルトの incrementSize を使用して、空のプールのケースを再現します。maxSize が incrementSize より小さい場合に、nativeClose と poolSize の減少後、プールが置換接続を作成できることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Describe your system
odbcPackage Version: 2.4.8- ODBC Driver: Progress OpenEdge ODBC Driver 8.0.0
- Database Name: OpenEdge
- Database Version: 11.7
- Database OS: Windows
- Node.js Version: 18.20.2
- Node.js OS: linux/amd64
Describe the bug
This bug is related to pooling.
On an initialized empty pool (with no active connections), if the incrementSize is larger than the maxSize, if no new connections are being created, no new connections can be created.
For example:
If there is only one connection in a pool and that single connection dies (i.e. the socket gets closed), the connection needs to be closed manually with nativeClose and poolSize needs to be decremented manually. We need to call nativeClose instead of close because close will just release that dead connection back into the pool without closing it.
In this state, no new connection can be made.
I discovered this with a pool maxSize of 5, initialSize of 1 and without defining the incrementSize (it defaults to 10).
Expected behavior
A new connection should be made on an empty pool regardless of the maxSize and incrementSize settings on the pool.
To Reproduce
- Connect to database using a pool with options
{ maxSize: 5, initialSize: 1, reuseConnections: true } - Force close the connection socket from on the database server
- Call nativeClose on the connection in the pool and decrement the poolSize
- Call connect on the pool to obtain a new connection.
Code
const query = async (query) => {
let odbcConnection = await connect()
for (let tries = 0; tries < maxNumberOfTries; tries++) {
try {
const res = await odbcConnection.query(query)
await odbcConnection.close()
return res
} catch (error) {
if (
error.odbcErrors?.[0]?.message ===
"[DataDirect][ODBC Progress OpenEdge Wire Protocol driver]Socket closed."
) {
await odbcConnection.nativeClose()
this.pool.poolSize--
odbcConnection = await connect()
}
}
}
throw new Error("Failed to query the database")
}
- The offending code:
I believe the issue stems from this if statement in /lib/Pool.js on line 211 and 212
https://github.com/IBM/node-odbc/blob/c1cbc136670c50a55813b391637fd465ea0f3e81/lib/Pool.js#L211
The main issue here is that it doesn't make sense for incrementSize to be less than maxSize, but the default incrementSize is 10, so any maxSize less than that can cause issues.
Maybe the best way to handle this would be set the default incrementSize to min(maxSize, 10), or change the logic in the if condition to handle this case.
- 主要言語
- JavaScript
- スター
- 159
- フォーク
- 92
- 平均マージ
- 5時間 59分
- マージ済み PR(30日)
- 3
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
IBM/node-odbc のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
security
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
[Bug] Sybase ASE: Encoding issue (works in msnodesqlv8, fails in node-odbc with \x1A artifacts)オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
似ている issue
-
check:passed feeds:remove
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
iptv-org/database#37176 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 9 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
hawk-digital-environments/HAWKI#443 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
feedback simulation workshop
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
githubnext/gh-aw-workshop#4370 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
AltimateAI/vscode-dbt-power-user#2089 ·