oracle / python-cx_Oracle

Python interface to Oracle Database now superseded by python-oracledb
https://oracle.github.io/python-cx_Oracle
Other
889 stars 361 forks source link

10 second delay when accessing an HighAvailabilty port 1539 environment... #622

Closed bostonareahuman closed 1 year ago

bostonareahuman commented 2 years ago
  1. What versions are you using? 8.3.0
  1. Describe the problem

t1 = perf_counter() dsn_tns = cx_Oracle.makedsn(config["MDMOWNER"]["SERVER"],config["MDMOWNER"]["PORT"],service_name=config["MDMOWNER"]["SID"]) cnx = cx_Oracle.connect(config["MDMOWNER"]["USER"],config["MDMOWNER"]["PASS"],dsn_tns) t2 = perf_counter()

print(str(t2-t1))

the t2-t1 is about 10 seconds for a connection

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

see above

cjbj commented 2 years ago

The 10 seconds is suspiciously like an Oracle Notification Service (ONS) timeout period. Your networking is probably not fully configured.

Can you try forcing off events mode? Create an oraaccess.xml file in your network configuration directory:

<?xml version="1.0" encoding="ASCII" ?> 
 <oraaccess xmlns="http://xmlns.oracle.com/oci/oraaccess"
  xmlns:oci="http://xmlns.oracle.com/oci/oraaccess"
  schemaLocation="http://xmlns.oracle.com/oci/oraaccess
  http://xmlns.oracle.com/oci/oraaccess.xsd">
  <default_parameters>
    <events>
      false
    </events>
  </default_parameters>
</oraaccess>

To confirm this file is being read, add a deliberate typo into one of the tags; Python etc will then throw an error like ORA-24296: error in processing the XML configuration file oraaccess.xml. Remove the error and then try your app.

bostonareahuman commented 2 years ago

@cjbj So this would be in the instantclient directory?

as a side note I downgraded to 7.3 cx and the issue disappeared. ;)

cjbj commented 2 years ago

The file location options are shown in https://cx-oracle.readthedocs.io/en/latest/user_guide/initialization.html#optional-oracle-client-configuration-files

stale[bot] commented 2 years ago

This issue has been automatically marked as inactive because it has not been updated recently. It will be closed if no further activity occurs. Thank you for your contributions.

cjbj commented 2 years ago

There are two things going on here, as far as I can tell:

  1. your network isn't configured 'properly' to allow ONS for event notifications. This may not be a concern if you don't want events.
  2. an uninitialized variable buglet introduced in about cx_Oracle 8.2 meant that the connection events mode might get enabled. The workaround - if you don't want it on - is to explicitly set it off at connection or pool creation time: events=False. This is easier than the oraacess.xml file solution shown above. Anthony has a patch for this. This buglet is not present in python-oracledb
cjbj commented 1 year ago

Closing this as fixed in python-oracledb.