Skip to content

Commit f1f8a3c

Browse files
committed
Let queueMax:0 disable queuing
1 parent a1bc3ea commit f1f8a3c

File tree

4 files changed

+50
-15
lines changed

4 files changed

+50
-15
lines changed

doc/api.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,7 @@ When the number of `pool.getConnection()` calls that have been
18201820
then any future `pool.getConnection()` calls will immediately return an error
18211821
and will not be queued.
18221822

1823-
If `queueMax` is 0, then the queue length is not limited.
1823+
If `queueMax` is -1, then the queue length is not limited.
18241824

18251825
The default value is 500.
18261826

@@ -1835,9 +1835,9 @@ oracledb.queueMax = 500;
18351835

18361836
#### <a name="propdbqueuerequests"></a> 3.2.24 `oracledb.queueRequests`
18371837

1838-
This property was removed in node-oracledb 3.0. Queuing is now always
1839-
enabled. See [Connection Pool Queue](#connpoolqueue) for more
1840-
information.
1838+
This property was removed in node-oracledb 3.0 and queuing was always enabled.
1839+
In node-oracledb 5.0, set `queueMax` to 0 to disable queuing. See [Connection
1840+
Pool Queue](#connpoolqueue) for more information.
18411841

18421842
#### <a name="propdbqueuetimeout"></a> 3.2.25 `oracledb.queueTimeout`
18431843

@@ -2231,7 +2231,7 @@ When the number of `pool.getConnection()` calls that have been
22312231
then any future `pool.getConnection()` calls will immediately return an error
22322232
and will not be queued.
22332233

2234-
If `queueMax` is 0, then the queue length is not limited.
2234+
If `queueMax` is -1, then the queue length is not limited.
22352235

22362236
The default value is 500.
22372237

@@ -2240,9 +2240,9 @@ This optional property overrides the
22402240

22412241
###### <a name="createpoolpoolattrsqueuerequests"></a> 3.3.1.1.15 `queueRequests`
22422242

2243-
This property was removed in node-oracledb 3.0. Queuing is now always
2244-
enabled. See [Connection Pool Queue](#connpoolqueue) for more
2245-
information.
2243+
This property was removed in node-oracledb 3.0 and queuing was always enabled.
2244+
In node-oracledb 5.0, set `queueMax` to 0 to disable queuing. See [Connection
2245+
Pool Queue](#connpoolqueue) for more information.
22462246

22472247
###### <a name="createpoolpoolattrsqueuetimeout"></a> 3.3.1.1.16 `queueTimeout`
22482248

@@ -5560,9 +5560,8 @@ See [`oracledb.queueMax`](#propdbqueuemax).
55605560

55615561
#### <a name="proppoolqueuerequests"></a> 8.1.10 `pool.queueRequests`
55625562

5563-
This property was removed in node-oracledb 3.0. Queuing is now always
5564-
enabled. See [Connection Pool Queue](#connpoolqueue) for more
5565-
information.
5563+
This property was removed in node-oracledb 3.0. See [Connection Pool
5564+
Queue](#connpoolqueue) for more information.
55665565

55675566
#### <a name="proppoolqueueTimeout"></a> 8.1.11 `pool.queueTimeout`
55685567

@@ -9893,7 +9892,7 @@ a [`sqlnet.ora`](#tnsadmin) file or [`CONNECT_TIMEOUT`][185] in a [connection
98939892
string](#easyconnect). When using a connection pool, these values affect the
98949893
time taken to establish each connection stored in the pool. The
98959894
[`queueTimeout`](#propdbqueuetimeout) and [`queueMax`](#propdbqueuemax) settings
9896-
control higher level pool behavior.
9895+
control higher-level pool behavior.
98979896

98989897
With Oracle Client 19c, timeouts can be passed in [Easy Connect
98999898
strings](#easyconnect), for example to timeout after 15 seconds:

lib/pool.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async function getConnection(a1) {
9797
if (this._connectionsOut >= poolMax) {
9898

9999
// when the queue is huge, throw error early without waiting for queue timeout
100-
if (this._connRequestQueue.length >= this.queueMax && this.queueMax > 0) {
100+
if (this._connRequestQueue.length >= this.queueMax && this.queueMax >= 0) {
101101
if (this._enableStats) {
102102
this._totalRequestsRejected += 1;
103103
}

test/list.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Overview of node-oracledb functional tests
6363
2.8.2 generates NJS-040 if request is queued and queueTimeout expires
6464
2.8.3 does not generate NJS-040 if request is queued for less time than queueTimeout
6565
2.8.4 generates NJS-076 if request exceeds queueMax
66+
2.8.5 generates NJS-076 if request exceeds queueMax 0
6667
2.9 _enableStats & _logStats functionality
6768
2.9.1 does not work after the pool has been terminated
6869
2.10 Close method
@@ -4734,4 +4735,4 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
47344735
239.1 disable prefetchRows by setting it to be 0
47354736
239.2 prefetchRows is enabled with default value
47364737
239.3 cursor bind OUT then bind IN
4737-
239.4 implicit binding type
4738+
239.4 implicit binding type

test/pool.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. */
1+
/* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. */
22

33
/******************************************************************************
44
*
@@ -863,6 +863,41 @@ describe('2. pool.js', function() {
863863
}
864864
);
865865
});
866+
867+
it('2.8.5 generates NJS-076 if request exceeds queueMax 0', function(done) {
868+
oracledb.createPool(
869+
{
870+
user : dbConfig.user,
871+
password : dbConfig.password,
872+
connectString : dbConfig.connectString,
873+
poolMin : 1,
874+
poolMax : 1,
875+
poolIncrement : 0,
876+
queueTimeout : 5000, // 5 seconds
877+
queueMax : 0
878+
},
879+
function(err, pool) {
880+
should.not.exist(err);
881+
882+
pool.getConnection(function(err, conn1) {
883+
should.not.exist(err);
884+
pool.getConnection(function(err, conn) {
885+
should.exist(err);
886+
(err.message.startsWith("NJS-076:")).should.be.true();
887+
should.not.exist(conn);
888+
conn1.close(function(err) {
889+
should.not.exist(err);
890+
891+
pool.close(function(err) {
892+
should.not.exist(err);
893+
done();
894+
});
895+
});
896+
});
897+
});
898+
});
899+
});
900+
866901
});
867902

868903
describe('2.9 _enableStats & _logStats functionality', function(){

0 commit comments

Comments
 (0)