Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[BUG] No new connections being made on empty pool when maxSize is less than incrementSize

オープン
#397 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript, node.js
領域
backend, database

調査の方向性

lib/Pool.js の211-212行目付近から始め、maxSize: 5、initialSize: 1、デフォルトの incrementSize を使用して、空のプールのケースを再現します。maxSize が incrementSize より小さい場合に、nativeClose と poolSize の減少後、プールが置換接続を作成できることを確認します。

索引モデルが issue の本文から書いたものです。

説明

Describe your system

  • odbc Package 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

  1. Connect to database using a pool with options { maxSize: 5, initialSize: 1, reuseConnections: true }
  2. Force close the connection socket from on the database server
  3. Call nativeClose on the connection in the pool and decrement the poolSize
  4. 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 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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

IBM/node-odbc のほかの issue

IBM/node-odbc の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。