Fixed bug that caused "Connection.is_healthy()" to return "True"

after a connection has been killed.
This commit is contained in:
Anthony Tuininga 2022-09-28 18:07:09 -06:00
parent bf4c2ce48d
commit 9db900c31d
4 changed files with 6 additions and 2 deletions

View File

@ -15,6 +15,8 @@ Thin Mode Changes
#) Fixed bug that prevented binding data of types DB_TYPE_ROWID and
DB_TYPE_UROWID.
#) Fixed bug that caused :meth:`Connection.is_healthy()` to return `True`
after a connection has been killed.
#) Internally, before a connection is returned from a pool, perform additional
checks in order to avoid returning a dead connection from the pool.

View File

@ -503,7 +503,7 @@ class Connection:
This function performs a local check. To fully check a connection's
health, use ping() which performs a round-trip to the database.
"""
return self._impl.get_is_healthy()
return self._impl is not None and self._impl.get_is_healthy()
@property
def ltxid(self) -> bytes:

View File

@ -325,7 +325,8 @@ cdef class ThinConnImpl(BaseConnImpl):
return self._internal_name
def get_is_healthy(self):
return not self._protocol._read_buf._session_needs_to_be_closed
return self._protocol._socket is not None \
and not self._protocol._read_buf._session_needs_to_be_closed
def get_ltxid(self):
return self._ltxid or b''

View File

@ -739,6 +739,7 @@ class TestCase(test_env.BaseTestCase):
admin_cursor.execute(sql)
self.assertRaisesRegex(oracledb.DatabaseError, "^DPY-4011:",
cursor.execute, "select user from dual")
self.assertFalse(conn.is_healthy())
def test_4359_kill_conn_in_context_manager(self):
"4359 - kill connection in cursor context manager"