Skip to content

Commit cc1e3ea

Browse files
Fixed bug with intermittent hang on some versions of Oracle Database when
using asyncio and the database raises an error and output variables are present (#278).
1 parent 2757a45 commit cc1e3ea

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

doc/src/release_notes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ Thin Mode Changes
1515

1616
#) Added support for using alternative event loop implementations like uvloop
1717
(`issue 276 <https://github.com/oracle/python-oracledb/issues/276>`__).
18+
#) Fixed bug with intermittent hang on some versions of Oracle Database when
19+
using asyncio and the database raises an error and output variables are
20+
present
21+
(`issue 278 <https://github.com/oracle/python-oracledb/issues/278>`__).
1822
#) Fixed bug when fetch variables contain output converters and a query is
1923
re-executed
2024
(`issue 271 <https://github.com/oracle/python-oracledb/issues/271>`__).

src/oracledb/impl/thin/protocol.pyx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -456,9 +456,6 @@ cdef class Protocol(BaseProtocol):
456456
cdef int _reset(self, Message message) except -1:
457457
cdef uint8_t marker_type, packet_type
458458

459-
# send reset marker
460-
self._send_marker(self._write_buf, TNS_MARKER_TYPE_RESET)
461-
462459
# read and discard all packets until a marker packet is received
463460
while True:
464461
packet_type = self._read_buf._current_packet.packet_type
@@ -469,11 +466,12 @@ cdef class Protocol(BaseProtocol):
469466
break
470467
self._read_buf.wait_for_packets_sync()
471468

472-
# read error packet; first skip as many marker packets as may be sent
473-
# by the server; if the server doesn't handle out-of-band breaks
474-
# properly, some quit immediately and others send multiple reset
475-
# markers (this addresses both situations without resulting in strange
476-
# errors)
469+
# send reset marker and then read error packet; first skip as many
470+
# marker packets as may be sent by the server; if the server doesn't
471+
# handle out-of-band breaks properly, some quit immediately and others
472+
# send multiple reset markers (this addresses both situations without
473+
# resulting in strange errors)
474+
self._send_marker(self._write_buf, TNS_MARKER_TYPE_RESET)
477475
while packet_type == TNS_PACKET_TYPE_MARKER:
478476
self._read_buf.wait_for_packets_sync()
479477
packet_type = self._read_buf._current_packet.packet_type
@@ -851,9 +849,6 @@ cdef class BaseAsyncProtocol(BaseProtocol):
851849
async def _reset(self):
852850
cdef uint8_t marker_type, packet_type
853851

854-
# send reset marker
855-
self._send_marker(self._write_buf, TNS_MARKER_TYPE_RESET)
856-
857852
# read and discard all packets until a marker packet is received
858853
while True:
859854
packet_type = self._read_buf._current_packet.packet_type
@@ -864,11 +859,13 @@ cdef class BaseAsyncProtocol(BaseProtocol):
864859
break
865860
await self._read_buf.wait_for_packets_async()
866861

867-
# read error packet; first skip as many marker packets as may be sent
868-
# by the server; if the server doesn't handle out-of-band breaks
869-
# properly, some quit immediately and others send multiple reset
870-
# markers (this addresses both situations without resulting in strange
871-
# errors)
862+
863+
# send reset marker and then read error packet; first skip as many
864+
# marker packets as may be sent by the server; if the server doesn't
865+
# handle out-of-band breaks properly, some quit immediately and others
866+
# send multiple reset markers (this addresses both situations without
867+
# resulting in strange errors)
868+
self._send_marker(self._write_buf, TNS_MARKER_TYPE_RESET)
872869
while packet_type == TNS_PACKET_TYPE_MARKER:
873870
await self._read_buf.wait_for_packets_async()
874871
packet_type = self._read_buf._current_packet.packet_type

0 commit comments

Comments
 (0)