python-cx_Oracle
python-cx_Oracle copied to clipboard
10 second delay when accessing an HighAvailabilty port 1539 environment...
- What versions are you using? 8.3.0
- 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
- Include a runnable Python script that shows the problem.
see above
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.
@cjbj So this would be in the instantclient directory?
as a side note I downgraded to 7.3 cx and the issue disappeared. ;)
The file location options are shown in https://cx-oracle.readthedocs.io/en/latest/user_guide/initialization.html#optional-oracle-client-configuration-files
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.
There are two things going on here, as far as I can tell:
- your network isn't configured 'properly' to allow ONS for event notifications. This may not be a concern if you don't want events.
- 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
Closing this as fixed in python-oracledb.