Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#397 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, node.js
Ambito
backend, database

Direzione di ricerca

Inizia in lib/Pool.js intorno alle righe 211-212 e riproduci il caso di un pool vuoto con maxSize: 5, initialSize: 1 e il valore predefinito di incrementSize. Verifica che il pool possa creare una connessione sostitutiva dopo nativeClose e il decremento di poolSize quando maxSize è minore di incrementSize.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
JavaScript
Stelle
159
Fork
92
Merge medio
5h 59m
PR unite (30g)
3

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di IBM/node-odbc

Tutte le issue di IBM/node-odbc

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.