@@ -558,8 +558,10 @@ For installation information, see the [Node-oracledb Installation Instructions][
558
558
559
559
## <a name="intro"></a> 1. Introduction
560
560
561
- The [*node-oracledb*][1] add-on for Node.js powers high performance Oracle Database applications.
562
- Applications can be written in TypeScript, or directly in JavaScript.
561
+ The [*node-oracledb*][1] add-on for Node.js powers high performance Oracle
562
+ Database applications. You can use node-oracledb in your Node.js TypeScript or
563
+ JavaScript code. This lets you easily write complex applications, or build
564
+ sopisticated web services using [REST][199] or [GraphQL][200].
563
565
564
566
This document shows how to use node-oracledb. The API reference is in the first
565
567
sections of this document and the [user manual](#usermanual) in subsequent
@@ -571,6 +573,7 @@ current Oracle Databases. However the documentation may describe some
571
573
database features that are in specific Oracle Database versions,
572
574
editions, or require additional database options or packs.
573
575
576
+
574
577
#### Node-oracledb Features
575
578
576
579
The node-oracledb feature highlights are:
@@ -8778,7 +8781,10 @@ If you set `UV_THREADPOOL_SIZE` too late, the setting will be ignored and the
8778
8781
default thread pool size of 4 will still be used. Note that
8779
8782
[`pool.getStatistics()`](#poolgetstatistics) and
8780
8783
[`pool.logStatistics()`](#poollogstatistics) can only give the value of the
8781
- variable, not the actual size of the thread pool created.
8784
+ variable, not the actual size of the thread pool created. On Linux you can use
8785
+ `pstack` to see how many threads are actually running. Note Node.js will
8786
+ create a small number of threads in addition to the expected number of worker
8787
+ threads.
8782
8788
8783
8789
The '[libuv][21]' library used by Node.js 12.5 and earlier limits the number of
8784
8790
threads to 128. In Node.js 12.6 onward the limit is 1024. You should restrict
@@ -8797,15 +8803,14 @@ number of worker threads may improve throughput and prevent [deadlocks][22].
8797
8803
8798
8804
#### <a name="parallelism"></a> 15.2.1 Parallelism on a Connection
8799
8805
8800
- Each connection to Oracle Database can only do one operation at a time.
8806
+ Oracle Database can only execute operations one at a time on each connection .
8801
8807
Examples of operations include `connection.execute()`,
8802
8808
`connection.executeMany()`, `connection.queryStream()`,
8803
8809
`connection.getDbObjectClass()`, `connection.commit()`, `connection.close()`,
8804
8810
[SODA](#sodaoverview) calls, and streaming from [Lobs](#lobclass). Multiple
8805
8811
connections may be in concurrent use, but each connection can only do one thing
8806
8812
at a time. Code will not run faster when parallel database operations are
8807
- attempted using a single connection because operations can only be executed
8808
- sequentially by node-oracledb.
8813
+ attempted using a single connection.
8809
8814
8810
8815
From node-oracledb 5.2, node-oracledb function calls that use a single
8811
8816
connection for concurrent database access will be queued in the JavaScript layer
@@ -10309,14 +10314,16 @@ appropriate application-specific recovery.
10309
10314
10310
10315
#### <a name="connectionpremclose"></a> 15.9.1 Preventing Premature Connection Closing
10311
10316
10312
- When connections are idle, external timeouts may disconnect them from the
10313
- database. This can impact scalability, cause connection storms, and lead to
10314
- application errors when invalid connections are attempted to be used.
10317
+ When connections are idle, external events may disconnect them from the
10318
+ database. Unnecessarily having to re-establish connections can impact
10319
+ scalability, cause connection storms, or lead to application errors when
10320
+ invalid connections are attempted to be used.
10315
10321
10316
10322
There are three components to a node-oracledb connection:
10317
10323
10318
10324
1. The memory structure in node-oracledb that is returned by a
10319
- `getConnection()` call. It may be stored in a connection pool.
10325
+ `getConnection()` call. It may be a standalone connection or stored in a
10326
+ connection pool.
10320
10327
10321
10328
2. The underlying network connection between the Oracle Client libraries and the database.
10322
10329
@@ -10325,17 +10332,19 @@ There are three components to a node-oracledb connection:
10325
10332
Node-oracledb connections may become unusable due to network dropouts, database
10326
10333
instance failures, exceeding user profile resource limits, or by explicit
10327
10334
session closure of the server process from a DBA. By default, idle connections
10328
- in connection pools are unaware of these changes, so a `pool.getConnection()`
10329
- call could successfully return a connection to the application that will not be
10330
- usable. An error would only occur when calling `connection.execute()`, or
10331
- similar.
10332
-
10333
- Disable any firewall that is killing idle connections. Also disable the
10334
- database [resource manager][101] and any user resource profile
10335
- [`IDLE_TIME`][100] setting so they do not terminate sessions. These issues can
10336
- be hidden by node-oracledb's automatic connection re-establishment features so
10337
- it is recommended to use [AWR][62] to check the connection rate, and then fix
10338
- underlying causes.
10335
+ (the memory structures) in connection pools are unaware of these events. A
10336
+ subsequent `pool.getConnection()` call could successfully return a "connection"
10337
+ to the application that will not be usable. An error would only occur when
10338
+ later calling functions like `connection.execute()`. Similarly, using a standalone
10339
+ connection where the network has dropped out, or the database instance is
10340
+ unavailable, will return an error.
10341
+
10342
+ To avoid the overhead of connection re-creation, disable any firewall that is
10343
+ killing idle connections. Also disable the database [resource manager][101]
10344
+ and any user resource profile [`IDLE_TIME`][100] setting so they do not
10345
+ terminate sessions. These issues can be hidden by node-oracledb's automatic
10346
+ connection re-establishment features so it is recommended to use [AWR][62] to
10347
+ check the connection rate, and then fix underlying causes.
10339
10348
10340
10349
With Oracle Client 19c, [`EXPIRE_TIME`][159] can be used in
10341
10350
[`tnsnames.ora`](#tnsnames) connect descriptors or in [Easy Connect
@@ -11178,8 +11187,9 @@ Output is the same as the previous non-resultSet example.
11178
11187
11179
11188
Each ResultSet should be closed when it is no longer needed.
11180
11189
11181
- Warning: You should not concurrently fetch data from nested
11182
- cursors in different data rows because this may give inconsistent results.
11190
+ Warning: You should not concurrently fetch data from nested cursors, for
11191
+ example with `Promise.all()`, in different data rows because this may give
11192
+ inconsistent results.
11183
11193
11184
11194
#### <a name="querymeta"></a> 16.1.6 Query Column Metadata
11185
11195
@@ -16826,7 +16836,7 @@ Node-oracledb's [`execute()`](#execute) and
16826
16836
[`queryStream()`](#querystream) methods use the [Oracle Call Interface
16827
16837
statement cache][61] to make re-execution of statements efficient.
16828
16838
This cache removes the need for the separate 'prepare' or 'parse'
16829
- method which is sometimes seen in other Oracle APIs: there is no
16839
+ methods which are sometimes seen in other Oracle APIs: there is no
16830
16840
separate method in node-oracledb.
16831
16841
16832
16842
Each non-pooled connection and each session in the connection pool has
@@ -16846,6 +16856,15 @@ reused. For example if there are more distinct statements than cache
16846
16856
slots, and the order of statement execution causes older statements to
16847
16857
be flushed from the cache before the statements are re-executed.
16848
16858
16859
+ Disabling the statement cache may also be useful in test and development
16860
+ environments where database schema objects are being recreated, or where
16861
+ identical query text is used with different `fetchAsString` or `fetchInfo` data
16862
+ types. Doing so can lead to the statement cache becoming invalid, and the
16863
+ application receiving various errors, for example *ORA-3106*. After a
16864
+ statement execution error is returned to the application, node-oracledb drops
16865
+ that statement from the cache. This allows subsequent re-executions of the
16866
+ statement using that connection to succeed.
16867
+
16849
16868
The statement cache size can be set globally with [stmtCacheSize](#propdbstmtcachesize):
16850
16869
16851
16870
```javascript
@@ -17549,3 +17568,5 @@ can be asked at [AskTom][158].
17549
17568
[196]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-C558F7CF-446E-4078-B045-0B3BB026CB3C
17550
17569
[197]: https://www.youtube.com/watch?v=PWFb7amjqCE
17551
17570
[198]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-951568BF-D798-4456-8478-15FEEBA0C78E
17571
+ [199]: https://blogs.oracle.com/oraclemagazine/build-rest-apis-for-nodejs-part-1
17572
+ [200]: https://blogs.oracle.com/opal/demo:-graphql-with-node-oracledb
0 commit comments