oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
307 stars 59 forks source link

Thin mode connection to standby database failed with TypeError on _MAX_OPEN_CURSORS #294

Closed theo-fokkinga closed 3 months ago

theo-fokkinga commented 4 months ago

After upgrading from oracledb 1.4.2 to 2.1.0b1, thin mode connections to a physical standby database opened MOUNTED fail with a TypeError.

Connections using thick mode work fine. Thin mode connections to a primary database opened READ WRITE are fine, but when opened MOUNTED the same issue.

  1. What versions are you using?

Database version: 19.21.0.0.0

platform.platform: Linux-5.4.17-2136.327.2.el7uek.x86_64-x86_64-with-glibc2.17 sys.maxsize > 2**32: True platform.python_version: 3.9.18 oracledb.version: 2.1.0b1

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

Error

  1. What error(s) or behavior you are seeing?

When calling the connect() function to connect to a standby database: oracledb.connect(dsn=connect_string, user=username, password=password, mode=mode)

The following error occurs:

Traceback (most recent call last):
  File "/eco/mounts/eco_orabackup1/users/fokkingats/python_tests/test_oracledb_set_connectparams2.py", line 23, in <module>
    oracledb.connect(dsn=connect_string, user=username, password=password, mode=mode)
  File "/home/fokkingats/.local/lib/python3.9/site-packages/oracledb-2.1.0b1-py3.9-linux-x86_64.egg/oracledb/connection.py", line 1149, in connect
    return conn_class(dsn=dsn, pool=pool, params=params, **kwargs)
  File "/home/fokkingats/.local/lib/python3.9/site-packages/oracledb-2.1.0b1-py3.9-linux-x86_64.egg/oracledb/connection.py", line 523, in __init__
    impl.connect(params_impl)
  File "src/oracledb/impl/thin/protocol.pyx", line 376, in oracledb.thin_impl.Protocol._process_message
  File "src/oracledb/impl/thin/connection.pyx", line 372, in oracledb.thin_impl.ThinConnImpl.connect
  File "src/oracledb/impl/thin/connection.pyx", line 338, in oracledb.thin_impl.ThinConnImpl._connect_with_params
  File "src/oracledb/impl/thin/connection.pyx", line 319, in oracledb.thin_impl.ThinConnImpl._connect_with_description
  File "src/oracledb/impl/thin/connection.pyx", line 292, in oracledb.thin_impl.ThinConnImpl._connect_with_address
  File "src/oracledb/impl/thin/protocol.pyx", line 315, in oracledb.thin_impl.Protocol._connect_phase_two
  File "src/oracledb/impl/thin/protocol.pyx", line 397, in oracledb.thin_impl.Protocol._process_message
  File "src/oracledb/impl/thin/protocol.pyx", line 376, in oracledb.thin_impl.Protocol._process_message
  File "src/oracledb/impl/thin/messages.pyx", line 309, in oracledb.thin_impl.Message.process
  File "src/oracledb/impl/thin/messages.pyx", line 187, in oracledb.thin_impl.Message._process_message
  File "src/oracledb/impl/thin/messages.pyx", line 1577, in oracledb.thin_impl.AuthMessage._process_return_parameters
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

This refers to the line

    self.conn_impl._max_open_cursors = \
        int(self.session_data.get("AUTH_MAX_OPEN_CURSORS"))

For testing purposes I changed this as follows, and then connections are established without the TypeError:

    self.conn_impl._max_open_cursors = \
        int(self.session_data.get("AUTH_MAX_OPEN_CURSORS", 100))
  1. Does your application call init_oracle_client()?

No, the error occurs only in thin mode. In thick mode no errors.

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

username = "sys"
password = "change_on_install"
mode = oracledb.AUTH_MODE_SYSDBA
connect_string = "standby-host.oracle.com:1521/stby_db"

oracledb.connect(dsn=connect_string, user=username, password=password, mode=mode)
anthony-tuininga commented 4 months ago

I discussed this internally and thick mode uses the value 0, so I have adjusted thin mode to do the same. If you are able to build from source you can verify that it works for you, too.

theo-fokkinga commented 4 months ago

Great, I tested with the latest source and the issue is resolved. Thanks for your quick response!

maciej-markowski commented 3 months ago

Hi, the same error is thrown when trying to connect to ASM instance, when using oracledb 2.0.1 installed through pip. I also tested with latest source and it resolves this issue. When can we expect this changes to be released and installable through pip?

anthony-tuininga commented 3 months ago

A new release should be available "soon". We are doing internal testing right now so I can't say exactly when but it should be within the next week or so. Thank you for your patience!

anthony-tuininga commented 3 months ago

This patch was included in version 2.1.0 which was just released.