python-cx_Oracle icon indicating copy to clipboard operation
python-cx_Oracle copied to clipboard

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

Open bostonareahuman opened this issue 2 years ago • 5 comments

  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

bostonareahuman avatar Apr 08 '22 19:04 bostonareahuman

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 avatar Apr 08 '22 21:04 cjbj

@cjbj So this would be in the instantclient directory?

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

bostonareahuman avatar Apr 08 '22 22:04 bostonareahuman

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

cjbj avatar Apr 08 '22 22:04 cjbj

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.

stale[bot] avatar Jun 12 '22 14:06 stale[bot]

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 avatar Jun 12 '22 22:06 cjbj

Closing this as fixed in python-oracledb.

cjbj avatar Apr 03 '23 00:04 cjbj