You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
The text was updated successfully, but these errors were encountered:
Describe your system
odbc
Package Version: 2.4.8Describe the bug
This bug is related to pooling.
On an initialized empty pool (with no active connections), if the
incrementSize
is larger than themaxSize
, 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
andpoolSize
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
andincrementSize
settings on the pool.To Reproduce
{ maxSize: 5, initialSize: 1, reuseConnections: true }
Code
I believe the issue stems from this if statement in /lib/Pool.js on line 211 and 212
node-odbc/lib/Pool.js
Line 211 in c1cbc13
The main issue here is that it doesn't make sense for
incrementSize
to be less thanmaxSize
, but the defaultincrementSize
is 10, so anymaxSize
less than that can cause issues.Maybe the best way to handle this would be set the default
incrementSize
tomin(maxSize, 10)
, or change the logic in the if condition to handle this case.The text was updated successfully, but these errors were encountered: