Skip to content

Commit 1674d8c

Browse files
Fixed bug that caused "Connection.is_healthy()" to return "True" after a
connection has been killed.
1 parent 6dda5b5 commit 1674d8c

File tree

5 files changed

+7
-3
lines changed

5 files changed

+7
-3
lines changed

doc/src/release_notes.rst

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

1616
#) Fixed bug that prevented binding data of types
1717
:data:`~oracledb.DB_TYPE_ROWID` and :data:`~oracledb.DB_TYPE_UROWID`.
18+
#) Fixed bug that caused :meth:`Connection.is_healthy()` to return `True`
19+
after a connection has been killed.
1820
#) Internally, before a connection is returned from a pool, perform additional
1921
checks in order to avoid returning a dead connection from the pool.
2022

src/oracledb/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ def is_healthy(self) -> bool:
503503
This function performs a local check. To fully check a connection's
504504
health, use ping() which performs a round-trip to the database.
505505
"""
506-
return self._impl.get_is_healthy()
506+
return self._impl is not None and self._impl.get_is_healthy()
507507

508508
@property
509509
def ltxid(self) -> bytes:

src/oracledb/impl/thin/connection.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ cdef class ThinConnImpl(BaseConnImpl):
325325
return self._internal_name
326326

327327
def get_is_healthy(self):
328-
return not self._protocol._read_buf._session_needs_to_be_closed
328+
return self._protocol._socket is not None \
329+
and not self._protocol._read_buf._session_needs_to_be_closed
329330

330331
def get_ltxid(self):
331332
return self._ltxid or b''

tests/test_4300_cursor_other.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ def test_4358_kill_conn_with_open_cursor(self):
739739
admin_cursor.execute(sql)
740740
self.assertRaisesRegex(oracledb.DatabaseError, "^DPY-4011:",
741741
cursor.execute, "select user from dual")
742+
self.assertFalse(conn.is_healthy())
742743

743744
def test_4359_kill_conn_in_context_manager(self):
744745
"4359 - kill connection in cursor context manager"

utils/templates/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def is_healthy(self) -> bool:
501501
This function performs a local check. To fully check a connection's
502502
health, use ping() which performs a round-trip to the database.
503503
"""
504-
return self._impl.get_is_healthy()
504+
return self._impl is not None and self._impl.get_is_healthy()
505505

506506
@property
507507
def ltxid(self) -> bytes:

0 commit comments

Comments
 (0)