Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bequeath connections are failing with ORA-12545 #114

Closed
theo-fokkinga opened this issue Dec 13, 2022 · 4 comments
Closed

Bequeath connections are failing with ORA-12545 #114

theo-fokkinga opened this issue Dec 13, 2022 · 4 comments
Labels
bug Something isn't working patch available

Comments

@theo-fokkinga
Copy link

  1. What versions are you using?

Database version: Oracle 19.17.0.0.0

platform.platform: Linux-5.4.17-2136.313.6.el7uek.x86_64-x86_64-with-glibc2.17
sys.maxsize > 2**32: True
platform.python_version: 3.9.16

oracledb.version: 1.2.1

  1. Is it an error or a hang or a crash?
    Error

  2. What error(s) or behavior you are seeing?
    When calling the connect function for a bequeath connection, like:

connection = oracledb.connect(mode=oracledb.AUTH_MODE_SYSDBA)

The following error occurs:

Traceback (most recent call last):
  File "example_failing_bequeath_connection.py", line 11, in <module>
    connection = oracledb.connect(mode=sysdba_mode)
  File "/home/john/python3_oracledb_121/lib/python3.9/site-packages/oracledb/connection.py", line 1013, in connect
    return conn_class(dsn=dsn, pool=pool, params=params, **kwargs)
  File "/home/john/python3_oracledb_121/lib/python3.9/site-packages/oracledb/connection.py", line 138, in __init__
    impl.connect(params_impl, pool_impl)
  File "src/oracledb/impl/thick/connection.pyx", line 387, in oracledb.thick_impl.ThickConnImpl.connect
  File "src/oracledb/impl/thick/utils.pyx", line 410, in oracledb.thick_impl._raise_from_odpi
  File "src/oracledb/impl/thick/utils.pyx", line 400, in oracledb.thick_impl._raise_from_info
oracledb.exceptions.DatabaseError: ORA-12545: Connect failed because target host or object does not exist
  1. Does your application call init_oracle_client()?
    Yes, running in thick mode.

  2. Include a runnable Python script that shows the problem.

import os
import oracledb

os.environ["ORACLE_HOME"] = "/u01/app/oracle/product/19.0.0.0/db_1"
os.environ["ORACLE_SID"] = "ORCL"
oracledb.init_oracle_client()
connection = oracledb.connect(mode=oracledb.AUTH_MODE_SYSDBA)

connection.close()

When running in debug mode I found that the connection is being made using the connect_string:

'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=None)(PORT=1521)))(CONNECT_DATA=)(SECURITY=(SSL_SERVER_DN_MATCH=ON)))'

This explains the ORA-12545 error message.

It looks like a regression bug in src/oracledb/impl/base/connect_params.pyx, in the get_connect_string function (commit 847004a) introduced in version 1.2.0.
In version 1.0.1 a fix was included to 'restore support for bequeath connection` (commit 5852bae), but the change in 1.2.0 altered the same line. In version 1.1.1 the error does not occur.

Just for testing purposes, I changed the code as follows and then bequeath connections are working fine:

--- a/src/oracledb/impl/base/connect_params.pyx
+++ b/src/oracledb/impl/base/connect_params.pyx
@@ -538,7 +538,7 @@ cdef class ConnectParamsImpl:
         will be a connect string built up from the components supplied when the
         object was built.
         """
-        if self._has_components:
+        if self._has_components and self._default_address.host is not None:
             return self.description_list.build_connect_string()
@theo-fokkinga theo-fokkinga added the bug Something isn't working label Dec 13, 2022
@anthony-tuininga
Copy link
Member

Thanks for the report. I'll get that corrected!

@anthony-tuininga
Copy link
Member

I have pushed a patch that should correct this issue and added a relevant test case. If you are able to build from source you can verify that it corrects your issue as well.

@theo-fokkinga
Copy link
Author

I can confirm that the issue is fixed with this patch included. Thanks!

@anthony-tuininga
Copy link
Member

This patch is included in version 1.2.2 which was just released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working patch available
Projects
None yet
Development

No branches or pull requests

2 participants