Skip to content

Commit 073fa6a

Browse files
Fix typo and add tests to check for that scenario.
1 parent 9b6216f commit 073fa6a

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

src/oracledb/impl/thin/pool.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ cdef class ThinPoolImpl(BaseThinPoolImpl):
587587
request.conn_impl.ping()
588588
request.conn_impl.set_call_timeout(0)
589589
except exceptions.Error:
590-
request.conn_impl._protocol.disconnect()
590+
request.conn_impl._protocol._disconnect()
591591
request.conn_impl = None
592592
else:
593593
conn_impl = self._create_conn_impl(request.params)

tests/test_2400_pool.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,26 @@ def test_2456(self):
10661066
with self.assertRaisesFullCode("DPY-2064"):
10671067
test_env.get_pool(min=3, max=2)
10681068

1069+
@unittest.skipIf(test_env.get_is_drcp(), "not supported with DRCP")
1070+
def test_2457(self):
1071+
"2457 - ping pooled connection on receiving dead connection error"
1072+
admin_conn = test_env.get_admin_connection()
1073+
pool = test_env.get_pool(min=1, max=1, ping_interval=0)
1074+
1075+
# kill connection in pool
1076+
with admin_conn.cursor() as admin_cursor:
1077+
with pool.acquire() as conn:
1078+
sid, serial = self.get_sid_serial(conn)
1079+
sql = f"alter system kill session '{sid},{serial}'"
1080+
admin_cursor.execute(sql)
1081+
1082+
# acquire connection which should succeed without failure
1083+
with pool.acquire() as conn:
1084+
with conn.cursor() as cursor:
1085+
cursor.execute("select user from dual")
1086+
(user,) = cursor.fetchone()
1087+
self.assertEqual(user, test_env.get_main_user().upper())
1088+
10691089

10701090
if __name__ == "__main__":
10711091
test_env.run_test_cases()

tests/test_5500_pool_async.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,26 @@ async def test_5542(self):
634634
with self.assertRaisesFullCode("DPY-2064"):
635635
test_env.get_pool_async(min=3, max=2)
636636

637+
@unittest.skipIf(test_env.get_is_drcp(), "not supported with DRCP")
638+
async def test_5543(self):
639+
"5543 - ping pooled connection on receiving dead connection error"
640+
admin_conn = await test_env.get_admin_connection_async()
641+
pool = test_env.get_pool_async(min=1, max=1, ping_interval=0)
642+
643+
# kill connection in pool
644+
with admin_conn.cursor() as admin_cursor:
645+
async with pool.acquire() as conn:
646+
sid, serial = await self.get_sid_serial(conn)
647+
sql = f"alter system kill session '{sid},{serial}'"
648+
await admin_cursor.execute(sql)
649+
650+
# acquire connection which should succeed without failure
651+
async with pool.acquire() as conn:
652+
with conn.cursor() as cursor:
653+
await cursor.execute("select user from dual")
654+
(user,) = await cursor.fetchone()
655+
self.assertEqual(user, test_env.get_main_user().upper())
656+
637657

638658
if __name__ == "__main__":
639659
test_env.run_test_cases()

0 commit comments

Comments
 (0)