Skip to content

Uncaught expection when a connection in a connection pool is unhealthy #1604

@JanneSalo

Description

@JanneSalo
  1. What versions are you using?

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

process.platform: `'linux'`
process.version: `'v18.17.1'`
process.arch: `'x64'`
require('oracledb').versionString: `'6.1.0'`
require('oracledb').oracleClientVersionString: `undefined`
  1. Is it an error or a hang or a crash?

Error

  1. What error(s) or behavior you are seeing?

If the acquired connection is not healthy, it's removed from the pool here. However, removing the connection from the pool may cause an exception to be thrown but not caught anywhere. It eventually ends up in our process.on('uncaughtException') handler. Since this expection is not thrown immediately rather than on next tick when the event handler for _removePoolConnection is run, it's hard for us catch these in any other way. Should the event handler for _removePoolConnection maybe handle exceptions in some way or should unhealthy connection be dropped in some other way than emitting _removePoolConnection event? Note that the same issue affects also other places where _removePoolConnection event is emitted, such as when idle connections are dropped from the pool.

Full stack trace:

Error: NJS-500: connection to the Oracle Database was broken
NJS-501: connection to host x.x.x.x port yyyy terminated unexpectedly. (CONNECTION_ID=...)
read ETIMEDOUT
    at NTTCP.checkErr (node_modules/oracledb/lib/thin/sqlnet/ntTcp.js:327:29)
    at NTTCP.send (node_modules/oracledb/lib/thin/sqlnet/ntTcp.js:339:10)
    at WritePacket._sendPacket (node_modules/oracledb/lib/thin/protocol/packet.js:481:24)
    at WritePacket.endRequest (node_modules/oracledb/lib/thin/protocol/packet.js:507:12)
    at Protocol._encodeMessage (node_modules/oracledb/lib/thin/protocol/protocol.js:111:19)
    at Protocol._processMessage (node_modules/oracledb/lib/thin/protocol/protocol.js:151:18)
    at ThinConnectionImpl.close (node_modules/oracledb/lib/thin/connection.js:76:30)
    at ThinPoolImpl._destroy (node_modules/oracledb/lib/thin/pool.js:235:24)
    at EventEmitter.<anonymous> (node_modules/oracledb/lib/thin/pool.js:109:18)
    at EventEmitter.emit (node:events:514:28)
  code: 'NJS-500'
}

The reason why the connections break in the first place is at our end, caused probably by firewalls terminating idle connections. Still, we'd like to be sure there are no suprising consequences of connections going unhealthy. We have experienced issues in this particular environment also with oracledb 5.5.0, but since it probably handles unhealthy connections on a lower level, we don't experience any uncaught exceptions. Timeouts do occur on oracledb 5.5.0 but our code is able to handle them gracefully. We are, however, able to mitigate the issue simply by setting expireTime: 1 (probably bigger values would also work) for the connection pool to ensure the connections stay healthy.

  1. Include a runnable Node.js script that shows the problem.

Unfortunately we cannot provide this, since the underlying problem of connections being dropped is specific to our environment. The problem starts occurring after our application has been running for some time. We use a fixed pool size of 4 (i.e. poolMin = poolMax) so idle connection scanning should not happen.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions