Skip to content

Commit 91ea42b

Browse files
Added support for multiple pools with DRCP.
1 parent ba425c4 commit 91ea42b

File tree

15 files changed

+197
-34
lines changed

15 files changed

+197
-34
lines changed

doc/src/api_manual/connect_params.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,15 @@ ConnectParams Methods
6262
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
6363
driver_name=oracledb.defaults.driver_name, use_sni=None, \
6464
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
65-
extra_auth_params=None, handle=None)
65+
extra_auth_params=None, pool_Name=None, handle=None)
6666

6767
Sets the values for one or more of the parameters of a ConnectParams
6868
object.
6969

70+
.. versionchanged:: 3.2.0
71+
72+
The ``pool_name`` parameter was added.
73+
7074
.. versionchanged:: 3.0.0
7175

7276
The ``use_sni``, ``thick_mode_dsn_passthrough``, ``extra_auth_params``
@@ -333,6 +337,16 @@ ConnectParams Attributes
333337

334338
.. versionadded:: 2.1.0
335339

340+
.. attribute:: ConnectParams.pool_name
341+
342+
This read-only attribute is a string that specifies the name of the pool
343+
when using multiple DRCP pools with Oracle Database 23.4 or later. See
344+
:ref:`DRCP Pool Names <poolnames>`.
345+
346+
This attribute is supported in both python-oracledb Thin and Thick modes.
347+
348+
.. versionadded:: 3.2.0
349+
336350
.. attribute:: ConnectParams.port
337351

338352
This read-only attribute is an integer that returns the port number on

doc/src/api_manual/module.rst

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Oracledb Methods
4747
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
4848
driver_name=oracledb.defaults.driver_name, use_sni=False, \
4949
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
50-
extra_auth_params=None, handle=0)
50+
extra_auth_params=None, pool_name=None, handle=0)
5151

5252
Constructor for creating a connection to the database. Returns a
5353
:ref:`Connection Object <connobj>`. All parameters are optional and can be
@@ -410,6 +410,11 @@ Oracledb Methods
410410
used in both the python-oracledb Thin and Thick modes. See
411411
:ref:`tokenauth`.
412412

413+
The ``pool_name`` parameter is expected to be a string which specifies the
414+
name of the pool when using multiple DRCP pools with Oracle Database 23.4
415+
or later. This value is used in both python-oracledb Thin and Thick modes.
416+
See :ref:`DRCP Pool Names <poolnames>`.
417+
413418
If the ``handle`` parameter is specified, it must be of type OCISvcCtx\*
414419
and is only of use when embedding Python in an application (like
415420
PowerBuilder) which has already made the connection. The connection thus
@@ -418,6 +423,10 @@ Oracledb Methods
418423
is ignored in the Thin mode. It should be used with extreme caution. The
419424
default value is *0*.
420425

426+
.. versionchanged:: 3.2.0
427+
428+
The ``pool_name`` parameter was added.
429+
421430
.. versionchanged:: 3.0.0
422431

423432
The ``pool_alias``, ``instance_name``, ``use_sni``,
@@ -470,7 +479,7 @@ Oracledb Methods
470479
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
471480
driver_name=oracledb.defaults.driver_name, use_sni=False, \
472481
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
473-
extra_auth_params=None, handle=0)
482+
extra_auth_params=None, pool_name=None, handle=0)
474483

475484
Constructor for creating a connection to the database. Returns an
476485
:ref:`AsyncConnection Object <asyncconnobj>`. All parameters are optional
@@ -760,9 +769,18 @@ Oracledb Methods
760769
This value is used in both the python-oracledb Thin and Thick modes. See
761770
:ref:`tokenauth`.
762771

772+
The ``pool_name`` parameter is expected to be a string which specifies the
773+
name of the pool when using multiple DRCP pools with Oracle Database 23.4
774+
or later. This value is used in both python-oracledb Thin and Thick modes.
775+
See :ref:`DRCP Pool Names <poolnames>`.
776+
763777
The ``thick_mode_dsn_passthrough`` and ``handle`` parameters are ignored in
764778
python-oracledb Thin mode.
765779

780+
.. versionchanged:: 3.2.0
781+
782+
The ``pool_name`` parameter was added.
783+
766784
.. versionchanged:: 3.0.0
767785

768786
The ``pool_alias``, ``instance_name``, ``use_sni``,
@@ -813,7 +831,7 @@ Oracledb Methods
813831
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
814832
driver_name=oracledb.defaults.driver_name, use_sni=False, \
815833
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
816-
extra_auth_params=None, handle=0)
834+
extra_auth_params=None, pool_name=None, handle=0)
817835

818836
Contains all the parameters that can be used to establish a connection to
819837
the database.
@@ -1130,11 +1148,20 @@ Oracledb Methods
11301148
used in both the python-oracledb Thin and Thick modes. See
11311149
:ref:`tokenauth`.
11321150

1151+
The ``pool_name`` parameter is expected to be a string which specifies the
1152+
name of the pool when using multiple DRCP pools with Oracle Database 23.4
1153+
or later. This value is used in both python-oracledb Thin and Thick modes.
1154+
See :ref:`DRCP Pool Names <poolnames>`.
1155+
11331156
The ``handle`` parameter is expected to be an integer which represents a
11341157
pointer to a valid service context handle. This value is only used in the
11351158
python-oracledb Thick mode. It should be used with extreme caution. The
11361159
default value is *0*.
11371160

1161+
.. versionchanged:: 3.2.0
1162+
1163+
The ``pool_name`` parameter was added.
1164+
11381165
.. versionchanged:: 3.0.0
11391166

11401167
The ``instance_name``, ``use_sni``, ``thick_mode_dsn_passthrough`` and
@@ -1196,7 +1223,7 @@ Oracledb Methods
11961223
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
11971224
driver_name=oracledb.defaults.driver_name, use_sni=False, \
11981225
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
1199-
extra_auth_params=None, handle=0)
1226+
extra_auth_params=None, pool_name=None, handle=0)
12001227

12011228
Creates a connection pool with the supplied parameters and returns the
12021229
:ref:`ConnectionPool object <connpool>` for the pool. See :ref:`Connection
@@ -1634,6 +1661,11 @@ Oracledb Methods
16341661
used in both the python-oracledb Thin and Thick modes. See
16351662
:ref:`tokenauth`.
16361663

1664+
The ``pool_name`` parameter is expected to be a string which specifies the
1665+
name of the pool when using multiple DRCP pools with Oracle Database 23.4
1666+
or later. This value is used in both python-oracledb Thin and Thick modes.
1667+
See :ref:`DRCP Pool Names <poolnames>`.
1668+
16371669
If the ``handle`` parameter is specified, it must be of type OCISvcCtx\*
16381670
and is only of use when embedding Python in an application (like
16391671
PowerBuilder) which has already made the connection. The connection thus
@@ -1642,6 +1674,10 @@ Oracledb Methods
16421674
is ignored in the Thin mode. It should be used with extreme caution. The
16431675
default value is *0*.
16441676

1677+
.. versionchanged:: 3.2.0
1678+
1679+
The ``pool_name`` parameter was added.
1680+
16451681
.. versionchanged:: 3.0.0
16461682

16471683
The ``pool_alias``, ``instance_name``, ``use_sni``,
@@ -1698,7 +1734,7 @@ Oracledb Methods
16981734
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
16991735
driver_name=oracledb.defaults.driver_name, use_sni=False, \
17001736
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
1701-
extra_auth_params=None, handle=0)
1737+
extra_auth_params=None, pool_name=None, handle=0)
17021738

17031739
Creates a connection pool with the supplied parameters and returns the
17041740
:ref:`AsyncConnectionPool object <asyncconnpoolobj>` for the pool.
@@ -2047,9 +2083,18 @@ Oracledb Methods
20472083
used in both the python-oracledb Thin and Thick modes. See
20482084
:ref:`tokenauth`.
20492085

2086+
The ``pool_name`` parameter is expected to be a string which specifies the
2087+
name of the pool when using multiple DRCP pools with Oracle Database 23.4
2088+
or later. This value is used in both python-oracledb Thin and Thick modes.
2089+
See :ref:`DRCP Pool Names <poolnames>`.
2090+
20502091
The ``handle`` and ``thick_mode_dsn_passthrough`` parameters are ignored in
20512092
python-oracledb Thin mode.
20522093

2094+
.. versionchanged:: 3.2.0
2095+
2096+
The ``pool_name`` parameter was added.
2097+
20532098
.. versionchanged:: 3.0.0
20542099

20552100
The ``pool_alias``, ``instance_name``, ``use_sni``,
@@ -2293,7 +2338,7 @@ Oracledb Methods
22932338
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
22942339
driver_name=oracledb.defaults.driver_name, use_sni=False, \
22952340
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
2296-
extra_auth_params=None, handle=0)
2341+
extra_auth_params=None, pool_name=None, handle=0)
22972342

22982343
Creates and returns a :ref:`PoolParams Object <poolparam>`. The object
22992344
can be passed to :meth:`oracledb.create_pool()`.
@@ -2674,11 +2719,20 @@ Oracledb Methods
26742719
used in both the python-oracledb Thin and Thick modes. See
26752720
:ref:`tokenauth`.
26762721

2722+
The ``pool_name`` parameter is expected to be a string which specifies the
2723+
name of the pool when using multiple DRCP pools with Oracle Database 23.4
2724+
or later. This value is used in both python-oracledb Thin and Thick modes.
2725+
See :ref:`DRCP Pool Names <poolnames>`.
2726+
26772727
The ``handle`` parameter is expected to be an integer which represents a
26782728
pointer to a valid service context handle. This value is only used in the
26792729
python-oracledb Thick mode. It should be used with extreme caution. The
26802730
default value is *0*.
26812731

2732+
.. versionchanged:: 3.2.0
2733+
2734+
The ``pool_name`` parameter was added.
2735+
26822736
.. versionchanged:: 3.0.0
26832737

26842738
The ``use_sni``, ``instance_name``, ``thick_mode_dsn_passthrough``,

doc/src/api_manual/pool_params.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,14 @@ PoolParams Methods
5353
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
5454
driver_name=oracledb.defaults.driver_name, use_sni=None, \
5555
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
56-
extra_auth_params=None, handle=None)
56+
extra_auth_params=None, pool_name=None, handle=None)
5757

5858
Sets one or more of the parameters.
5959

60+
.. versionchanged:: 3.2.0
61+
62+
The ``pool_name`` parameter was added.
63+
6064
.. versionchanged:: 3.0.0
6165

6266
The ``use_sni``, ``thick_mode_dsn_passthrough``,

doc/src/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Thick Mode Changes
4747
Common Changes
4848
++++++++++++++
4949

50+
#) Added parameter ``pool_name`` to connection and pool creation methods to
51+
support Oracle Database 23ai multi-pool :ref:`drcp`.
5052
#) Added Instance Principal authentication support when using
5153
:ref:`OCI Cloud Native Authentication <cloudnativeauthoci>`.
5254
#) Use GitHub Arm Linux runner for builds. Supplied by wojiushixiaobai

doc/src/user_guide/connection_handling.rst

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2893,7 +2893,11 @@ Enabling DRCP in Oracle Database
28932893
Oracle Database versions prior to 21c can have a single DRCP connection pool.
28942894
From Oracle Database 21c, each pluggable database can optionally have its own
28952895
pool, or can use the container level pool. From Oracle Database 23ai, you can
2896-
create multiple pools at the pluggable, or container, database level.
2896+
create multiple pools at the pluggable, or container, database level. This
2897+
multi-pool feature is useful where different applications connect to the same
2898+
database, but there is a concern that one application's use of the pool may
2899+
impact other applications. If this is not the case, a single pool may allow
2900+
best resource sharing on the database host.
28972901

28982902
Note that DRCP is already enabled in Oracle Autonomous Database and pool
28992903
management is different to the steps below.
@@ -3033,7 +3037,7 @@ To enable connections to use DRCP pooled servers, you can:
30333037
server_type="pooled",
30343038
cclass="MYAPP")
30353039
3036-
**DRCP Connection Class Names**
3040+
**DRCP Connection Classes**
30373041

30383042
The best practice is to specify a ``cclass`` class name when creating a
30393043
python-oracledb connection pool. This user-chosen name provides some
@@ -3071,14 +3075,37 @@ default, python-oracledb pooled connections use ``PURITY_SELF`` and standalone
30713075
connections use ``PURITY_NEW``.
30723076

30733077
To limit session sharing, you can explicitly require that new session memory be
3074-
allocated each time :meth:`~ConnectionPool.acquire()` is called:
3078+
allocated each time :meth:`~ConnectionPool.acquire()` is called. Do this when
3079+
creating a driver connection pool by specifying the ``purity`` as
3080+
``PURITY_NEW``:
30753081

30763082
.. code-block:: python
30773083
30783084
pool = oracledb.create_pool(user="hr", password=userpwd, dsn="dbhost.example.com/orclpdb:pooled",
30793085
min=2, max=5, increment=1,
30803086
cclass="MYAPP", purity=oracledb.PURITY_NEW)
30813087
3088+
The overheads can impact ultimate scalability.
3089+
3090+
.. _poolnames:
3091+
3092+
**DRCP Pool Names**
3093+
3094+
From Oracle Database 23ai, multiple DRCP pools can be created by setting a pool
3095+
name at DRCP pool creation time. Applications can then specifiy which DRCP pool
3096+
to use by passing the ``pool_name`` parameter during connection, or connection
3097+
pool, creation, for example:
3098+
3099+
.. code-block:: python
3100+
3101+
pool = oracledb.create_pool(user="hr", password=userpwd,
3102+
dsn="dbhost.example.com/orclpdb:pooled",
3103+
min=2, max=5, increment=1,
3104+
cclass="MYAPP", pool_name="MYPOOL")
3105+
3106+
When specifying a pool name, you should still set a connection class name to
3107+
allow efficient use of the pool's resources.
3108+
30823109
**Acquiring a DRCP Connection**
30833110

30843111
Once DRCP has been enabled and the driver connection pool has been created with
@@ -3132,39 +3159,40 @@ other users:
31323159
. . .
31333160
connection.close()
31343161
3135-
Setting the DRCP Connection Class and Purity in the Connection String
3136-
---------------------------------------------------------------------
3162+
Setting DRCP Parameters in Connection Strings
3163+
---------------------------------------------
31373164

3138-
Although setting the DRCP connection class and purity in the application is
3139-
preferred, sometimes it is not possible to modify an existing code base. For
3140-
these applications, you can specify the class and purity along with the pooled
3141-
server option in the connection string.
3165+
Setting the DRCP connection class, purity, and pool name as function parameters
3166+
in the application is preferred, but sometimes it is not possible to modify an
3167+
existing code base. For these applications, you can specify the values along
3168+
with the pooled server option in the connection string.
3169+
3170+
You can specify the class and purity options in connection strings when using
3171+
Oracle Database 21c, or later. You can specify the pool name when using Oracle
3172+
Database 23ai, or later.
31423173

31433174
For example with the :ref:`Easy Connect <easyconnect>` syntax::
31443175

3145-
dbhost.example.com/orclpdb:pooled?pool_connection_class=MYAPP&pool_purity=self
3176+
dbhost.example.com/orclpdb:pooled?pool_connection_class=MYAPP&pool_purity=self&pool_name=MYPOOL
31463177

3147-
or by using a :ref:`TNS Alias <netservice>` in a
3178+
Or by using a :ref:`TNS Alias <netservice>` in a
31483179
:ref:`tnsnames.ora <optnetfiles>` file::
31493180

31503181
customerpool = (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)
31513182
(HOST=dbhost.example.com)
31523183
(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orclpdb)
31533184
(SERVER=POOLED)
31543185
(POOL_CONNECTION_CLASS=MYAPP)
3155-
(POOL_PURITY=SELF)))
3156-
3157-
You can specify the class and purity options in connection strings when using
3158-
python-oracledb Thin mode with Oracle Database 21c, or later.
3159-
3160-
For python-oracledb Thick mode, setting these options in the connection string
3161-
is supported if you are using Oracle Database 21c (or later) and Oracle Client
3162-
19c (or later). However, explicitly specifying the purity as *SELF* in this way
3163-
may cause some unusable connections in a python-oracledb Thick mode connection
3164-
pool to not be terminated. In summary, if you cannot programmatically set the
3165-
class name and purity, or cannot use python-oracledb Thin mode, then avoid
3166-
explicitly setting the purity as a connection string parameter when using a
3167-
local python-oracledb connection pool in Thick mode.
3186+
(POOL_PURITY=SELF)
3187+
(POOL_NAME=MYPOOL)))
3188+
3189+
Explicitly specifying the purity as *SELF* in a connection string may cause
3190+
some unusable connections in a python-oracledb Thick mode connection pool to
3191+
not be terminated, potentially eventually rendering all connections in the pool
3192+
to be unusable. If you cannot programmatically set the class name and purity,
3193+
or cannot use python-oracledb Thin mode, then avoid explicitly setting the
3194+
purity as a connection string parameter when using a local python-oracledb
3195+
Thick mode connection pool.
31683196

31693197
.. _monitoringdrcp:
31703198

src/oracledb/base_impl.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ cdef class Description(ConnectParamsNode):
503503
public str cclass
504504
public str connection_id_prefix
505505
public str pool_boundary
506+
public str pool_name
506507
public uint32_t purity
507508
public bint ssl_server_dn_match
508509
public bint use_tcp_fast_open

0 commit comments

Comments
 (0)