Skip to content

Commit db9d460

Browse files
committed
Work on pool ping section. Reduce duplication. Put important stuff up the top
1 parent f7cb4a9 commit db9d460

File tree

1 file changed

+44
-47
lines changed

1 file changed

+44
-47
lines changed

doc/api.md

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -770,16 +770,16 @@ replaces explicit pinging.
770770

771771
With Oracle client 12.1 or earlier, unless `poolPingInterval` is `0`,
772772
it is possible for un-usable connections to be returned by a pool
773-
`getConnection()`. Since it is also possible for connections to
774-
become unusable after `getConnection()` is called, applications should
773+
`getConnection()` call. Since it is also possible for network outages
774+
to occur after `getConnection()` is called, applications should
775775
implement appropriate statement execution error checking.
776776

777777
The default value is `60` seconds. Possible values for `poolPingInterval` are:
778778

779-
Value | Behavior of a Pool `getConnection()` call
779+
`poolPingInterval` Value | Behavior of a Pool `getConnection()` Call
780780
----------|------------------------------------------
781781
`n` < `0` | Never checks for connection aliveness
782-
`0` | Always checks for connection aliveness. There is some overhead in performing a ping so non-zero values are recommended for most applications
782+
`n` = `0` | Always checks for connection aliveness. There is some overhead in performing a ping so non-zero values are recommended for most applications
783783
`n` > `0` | Checks aliveness if the connection has been idle in the pool (not "checked out" to the application by `getConnection()`) for at least `n` seconds
784784

785785
This property may be overridden when [creating a connection pool](#createpool).
@@ -789,7 +789,7 @@ See [Connection Pool Pinging](#connpoolpinging) for more discussion.
789789
##### Example
790790
```javascript
791791
var oracledb = require('oracledb');
792-
oracledb.poolPingInterval = 60;
792+
oracledb.poolPingInterval = 60; // seconds
793793
```
794794

795795
#### <a name="propdbpooltimeout"></a> 3.2.14 `oracledb.poolTimeout`
@@ -2943,35 +2943,39 @@ Environment Variable | Description
29432943
29442944
#### <a name="connpoolpinging"></a> 8.3.4 Connection Pool Pinging
29452945
2946-
If node-oracledb uses Oracle client 12.1 or earlier, and when
2947-
connections are idle in a connection pool (not "checked out" to the
2948-
application by `getConnection()`), there is the possibility that a
2949-
network or Database instance failure makes those connections unusable.
2950-
A `getConnection()` call will happily return a connection from the
2951-
pool but an error occurs when the application later uses the
2952-
connection.
2953-
2954-
Version 12.2 of the underlying Oracle client library has a
2955-
lightweight, always-enabled connection check. It will return a valid
2956-
connection to the node-oracledb driver, which in turn returns it via
2957-
`getConnection()`. When node-oracledb is built with Oracle client
2958-
12.2, then the value of the `poolPingInterval` attribute described
2959-
below is ignored and no explicit ping is executed because it is not
2960-
needed.
2946+
Node-oracledb can 'ping' connections returned from pooled
2947+
`getConnection()` calls to check for their aliveness. The frequency
2948+
of pinging can be controlled with
2949+
the [`oracledb.poolPingInterval`](#propdbpoolpinginterval) property or
2950+
during [pool creation](#createpool). The default ping interval is
2951+
`60` seconds.
2952+
2953+
Without pinging, when connections are idle in a connection pool, there
2954+
is the possibility that a network or Database instance failure makes
2955+
those connections unusable. A `getConnection()` call will happily
2956+
return a connection from the pool but an error will occur when the
2957+
application later uses the connection.
2958+
2959+
Note that explicit pinging is unnecessary and is not performed when
2960+
node-oracledb is built with version 12.2 of the underlying Oracle
2961+
client library. This has its own lightweight, always-enabled
2962+
connection check. It will return a valid connection to the
2963+
node-oracledb driver, which in turn returns it via `getConnection()`.
2964+
The value of `poolPingInterval` is ignored.
29612965
29622966
With Oracle client 12.1 and earlier, when a
29632967
pool [`getConnection()`](#getconnectionpool) is called and the
2964-
connection has been idle in the pool for at least `60` seconds then an
2965-
internal "ping" will be performed first to check the aliveness of the
2966-
connection. At the cost of some overhead for infrequently accessed
2967-
connection pools, connection pinging improves the chance a pooled
2968-
connection is valid when it is used because identified un-unusable
2969-
connections will not be returned to the application by
2970-
`getConnection()`.
2971-
2972-
For active applications that are getting and releasing connections
2973-
rapidly, the connections will not have been idle longer than
2974-
`poolPingInterval` and no pings will be needed.
2968+
connection has been idle in the pool (not "checked out" to the
2969+
application by `getConnection()`) for the specified `poolPingInterval`
2970+
then an internal "ping" will be performed first. At the cost of some
2971+
overhead for infrequently accessed connection pools, connection
2972+
pinging improves the chance a pooled connection is valid when it is
2973+
first used because identified un-unusable connections will not be
2974+
returned to the application by `getConnection()`. For active
2975+
applications that are getting and releasing connections rapidly, the
2976+
connections will generally not have been idle longer than
2977+
`poolPingInterval` so no pings will be performed and there will be no
2978+
overhead.
29752979
29762980
If a ping detects the connection is invalid, for example if the
29772981
network had disconnected, then node-oracledb internally drops the
@@ -2986,24 +2990,17 @@ repeated until:
29862990
Applications should continue to do appropriate error checking when
29872991
using connections in case they have become invalid in the time since
29882992
`getConnection()` was called. This error checking will also protect
2989-
against cases where there was a network outage out but a connection was idle
2990-
in the pool for less than `60` seconds and so `getConnection()` did
2991-
not ping. In all cases, when a bad connection
2992-
is [released](#connectionclose) back to the pool, the connection is
2993-
automatically destroyed. This allows a valid connection to be opened
2994-
by a subsequent `getConnection()` call.
2995-
2996-
The default ping interval is `60` seconds. The interval can be set with
2997-
the [`oracledb.poolPingInterval`](#propdbpoolpinginterval) property or
2998-
during [pool creation](#createpool).
2993+
against cases where there was a network outage but a connection was
2994+
idle in the pool for less than `poolPingInterval` seconds and so
2995+
`getConnection()` did not ping.
29992996
3000-
Possible values for `poolPingInterval` are:
2997+
In all cases, when a bad connection is [released](#connectionclose)
2998+
back to the pool, the connection is automatically destroyed. This
2999+
allows a valid connection to be opened by some subsequent
3000+
`getConnection()` call.
30013001
3002-
Value | Behavior of a Pool `getConnection()` call
3003-
----------|------------------------------------------
3004-
`n` < `0` | Never checks for connection aliveness
3005-
`0` | Always checks for connection aliveness. There is some overhead in performing a ping so non-zero values are recommended for most applications
3006-
`n` > `0` | Checks aliveness if the connection has been idle in the pool (not "checked out" to the application by `getConnection()`) for at least `n` seconds
3002+
You can tune `poolPingInterval` to meet your quality of service
3003+
requirements.
30073004
30083005
### <a name="drcp"></a> 8.4 Database Resident Connection Pooling (DRCP)
30093006

0 commit comments

Comments
 (0)