Skip to content

Commit d8c38e4

Browse files
Fixed bug when a connection pool internally makes an attempt to ping a
closed connection (#482).
1 parent 073fa6a commit d8c38e4

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ Thin Mode Changes
2222
#) Emulate support for :meth:`Queue.deqmany()` with JSON payloads when using
2323
Oracle Database 21c by internally calling :meth:`Queue.deqone()` as many
2424
times as needed.
25+
#) Fixed bug when a connection pool internally makes an attempt to ping a
26+
closed connection
27+
(`issue 482 <https://github.com/oracle/python-oracledb/issues/482>`__).
2528
#) Fixed bug when connecting with asyncio using the parameter ``https_proxy``.
2629
#) Fixed regression when connecting where only the host specified by the
2730
``https_proxy`` parameter can successfully perform name resolution.

src/oracledb/impl/thin/packet.pyx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,13 @@ cdef class ReadBuffer(Buffer):
660660
cdef:
661661
bint notify_waiter
662662
Packet packet
663-
packet = self._transport.read_packet()
664-
self._process_packet(packet, &notify_waiter, False)
665-
if notify_waiter:
666-
self._start_packet()
663+
packet = self._transport.read_packet(raise_exc=False)
664+
if packet is None:
665+
self._pending_error_num = TNS_ERR_SESSION_SHUTDOWN
666+
else:
667+
self._process_packet(packet, &notify_waiter, False)
668+
if notify_waiter:
669+
self._start_packet()
667670

668671
cdef bint has_response(self):
669672
"""

src/oracledb/impl/thin/transport.pyx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ cdef class Transport:
332332
self._transport = transport
333333
self._transport_num = sock.fileno()
334334

335-
cdef Packet read_packet(self):
335+
cdef Packet read_packet(self, bint raise_exc=True):
336336
"""
337337
Reads a packet from the transport.
338338
"""
@@ -344,10 +344,15 @@ cdef class Transport:
344344
try:
345345
data = self._transport.recv(self._max_packet_size)
346346
except ConnectionResetError as e:
347+
self._transport = None
348+
if not raise_exc:
349+
return None
347350
errors._raise_err(errors.ERR_CONNECTION_CLOSED, str(e),
348351
cause=e)
349352
if len(data) == 0:
350353
self.disconnect()
354+
if not raise_exc:
355+
return None
351356
errors._raise_err(errors.ERR_CONNECTION_CLOSED)
352357
packet = self.extract_packet(data)
353358
return packet

0 commit comments

Comments
 (0)