Skip to content

Commit

Permalink
Fixed bug when connecting to a database using listener redirects with
Browse files Browse the repository at this point in the history
asyncio (#285).
  • Loading branch information
anthony-tuininga committed Feb 18, 2024
1 parent 2baa27f commit 3ab90d9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
4 changes: 4 additions & 0 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ Thin Mode Changes
#) Fixed bug in calculating the :data:`Connection.thin` attribute.
#) Fixed bug in processing metadata that spans multiple packets when using
:ref:`asyncio <asyncio>`.
#) Fixed bug when connecting to a database using listener redirects when using
:ref:`asyncio <asyncio>`
(`issue 285 <https://github.com/oracle/python-oracledb/issues/285>`__).


Thick Mode Changes
++++++++++++++++++
Expand Down
31 changes: 19 additions & 12 deletions src/oracledb/impl/thin/protocol.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ cdef class BaseProtocol:
self._write_buf._transport = None
transport.disconnect()

cdef int _post_connect(self, BaseThinConnImpl conn_impl,
AuthMessage auth_message) except -1:
""""
Performs activities after the connection has completed. The protocol
must be marked to indicate that the connect is no longer in progress,
which allows the normal break/reset mechanism to fire. The session must
also be marked as not needing to be closed since for listener redirects
the packet may indicate EOF for the initial connection that is
established.
"""
conn_impl.warning = auth_message.warning
self._read_buf._session_needs_to_be_closed = False
self._in_connect = False

cdef int _release_drcp_session(self, BaseThinConnImpl conn_impl,
uint32_t release_mode) except -1:
"""
Expand Down Expand Up @@ -297,14 +311,8 @@ cdef class Protocol(BaseProtocol):
if auth_message.resend:
self._process_message(auth_message)

# mark protocol to indicate that connect is no longer in progress; this
# allows the normal break/reset mechanism to fire; also mark the
# session as not needing to be closed since for listener redirects
# the packet may indicate EOF for the initial connection that is
# established
conn_impl.warning = auth_message.warning
self._read_buf._session_needs_to_be_closed = False
self._in_connect = False
# perform post connect activities
self._post_connect(conn_impl, auth_message)

cdef int _connect_tcp(self, ConnectParamsImpl params,
Description description, Address address, str host,
Expand Down Expand Up @@ -648,10 +656,9 @@ cdef class BaseAsyncProtocol(BaseProtocol):
if auth_message.resend:
await self._process_message(auth_message)

# mark protocol to indicate that connect is no longer in progress; this
# allows the normal break/reset mechanism to fire
conn_impl.warning = auth_message.warning
self._in_connect = False
# perform post connect activities
self._post_connect(conn_impl, auth_message)


async def _connect_tcp(self, ConnectParamsImpl params,
Description description, Address address, str host,
Expand Down

0 comments on commit 3ab90d9

Please sign in to comment.