Skip to content

Commit 6bdd53d

Browse files
Fixed bug which caused Connection.call_timeout to be reset to zero when
a ping is internally executed by the pool before the connection is returned to the user (#558).
1 parent cea932e commit 6bdd53d

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

doc/src/release_notes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ oracledb `3.5.0 <https://github.com/oracle/python-oracledb/compare/v3.4.1...v3.5
1919
Thin Mode Changes
2020
+++++++++++++++++
2121

22+
#) Fixed bug which caused :data:`Connection.call_timeout` to be reset to zero
23+
when a ping is internally executed by the pool before the connection is
24+
returned to the user
25+
(`issue 558 <https://github.com/oracle/python-oracledb/issues/558>`__).
2226
#) Fixed bug when decoding PL/SQL booleans in Oracle Database 12.1
2327
(`issue 565 <https://github.com/oracle/python-oracledb/issues/565>`__).
2428
#) Fixed bug when a :ref:`DbObject <dbobject>` instance contains an attribute

src/oracledb/impl/thin/pool.pyx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,13 +579,16 @@ cdef class ThinPoolImpl(BaseThinPoolImpl):
579579
"""
580580
Processes a request.
581581
"""
582-
cdef BaseThinConnImpl conn_impl
582+
cdef:
583+
BaseThinConnImpl conn_impl
584+
uint32_t orig_call_timeout
583585
try:
584586
if request.requires_ping:
585587
try:
588+
orig_call_timeout = request.conn_impl._call_timeout
586589
request.conn_impl.set_call_timeout(self._ping_timeout)
587590
request.conn_impl.ping()
588-
request.conn_impl.set_call_timeout(0)
591+
request.conn_impl.set_call_timeout(orig_call_timeout)
589592
except exceptions.Error:
590593
request.conn_impl._protocol._disconnect()
591594
request.conn_impl = None
@@ -772,13 +775,16 @@ cdef class AsyncThinPoolImpl(BaseThinPoolImpl):
772775
"""
773776
Processes a request.
774777
"""
775-
cdef BaseThinConnImpl conn_impl
778+
cdef:
779+
BaseThinConnImpl conn_impl
780+
uint32_t orig_call_timeout
776781
try:
777782
if request.requires_ping:
778783
try:
784+
orig_call_timeout = request.conn_impl._call_timeout
779785
request.conn_impl.set_call_timeout(self._ping_timeout)
780786
await request.conn_impl.ping()
781-
request.conn_impl.set_call_timeout(0)
787+
request.conn_impl.set_call_timeout(orig_call_timeout)
782788
except exceptions.Error:
783789
request.conn_impl._protocol._disconnect()
784790
request.conn_impl = None

tests/test_2400_pool.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -----------------------------------------------------------------------------
2-
# Copyright (c) 2020, 2025, Oracle and/or its affiliates.
2+
# Copyright (c) 2020, 2026, Oracle and/or its affiliates.
33
#
44
# This software is dual-licensed to you under the Universal Permissive License
55
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
@@ -1110,3 +1110,18 @@ def test_2458(test_env):
11101110
with test_env.assert_raises_full_code("ORA-01017"):
11111111
pool = test_env.get_pool(password=test_env.main_password + "X")
11121112
pool.acquire()
1113+
1114+
1115+
def test_2459(test_env):
1116+
"2459 - verify call_timeout is unchanged after internal ping performed"
1117+
desired_value = 5000
1118+
1119+
def callback(conn, tag):
1120+
conn.call_timeout = desired_value
1121+
1122+
pool = test_env.get_pool(session_callback=callback, ping_interval=0)
1123+
with pool.acquire() as conn:
1124+
assert conn.call_timeout == desired_value
1125+
with pool.acquire() as conn:
1126+
assert conn.call_timeout == desired_value
1127+
pool.close()

tests/test_5500_pool_async.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -----------------------------------------------------------------------------
2-
# Copyright (c) 2023, 2025, Oracle and/or its affiliates.
2+
# Copyright (c) 2023, 2026, Oracle and/or its affiliates.
33
#
44
# This software is dual-licensed to you under the Universal Permissive License
55
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
@@ -684,3 +684,18 @@ async def test_5544(test_env):
684684
pool = test_env.get_pool_async(password=test_env.main_password + "X")
685685
with test_env.assert_raises_full_code("ORA-01017"):
686686
await pool.acquire()
687+
688+
689+
async def test_5545(test_env):
690+
"5545 - verify call_timeout is unchanged after internal ping performed"
691+
desired_value = 5000
692+
693+
async def callback(conn, tag):
694+
conn.call_timeout = desired_value
695+
696+
pool = test_env.get_pool_async(session_callback=callback, ping_interval=0)
697+
async with pool.acquire() as conn:
698+
assert conn.call_timeout == desired_value
699+
async with pool.acquire() as conn:
700+
assert conn.call_timeout == desired_value
701+
await pool.close()

0 commit comments

Comments
 (0)