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

TypeError: cannot convert 'NoneType' object to bytearray when connecting to oracledb server 19.2 in thin mode

Open abma opened this issue 3 years ago • 9 comments

server:

Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.16.0.0.0

client:

>>> print("platform.platform:", platform.platform())
platform.platform: Linux-5.10.0-17-amd64-x86_64-with-glibc2.31
>>> print("sys.maxsize > 2**32:", sys.maxsize > 2**32)
sys.maxsize > 2**32: True
>>> print("platform.python_version:", platform.python_version())
platform.python_version: 3.9.2
>>> print("oracledb.__version__:", oracledb.__version__)
oracledb.__version__: 1.0.3

thats the script:

import oracledb
c = oracledb.connect(user="user", password="mypassword", dsn="servername:1521/orcl")

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/oracledb/connection.py", line 1000, in connect
    return conn_class(dsn=dsn, pool=pool, params=params, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/oracledb/connection.py", line 128, in __init__
    impl.connect(params_impl)
  File "src/oracledb/impl/thin/connection.pyx", line 294, in oracledb.thin_impl.ThinConnImpl.connect
  File "src/oracledb/impl/thin/connection.pyx", line 184, in oracledb.thin_impl.ThinConnImpl._connect_with_params
  File "src/oracledb/impl/thin/connection.pyx", line 157, in oracledb.thin_impl.ThinConnImpl._connect_with_description
  File "src/oracledb/impl/thin/connection.pyx", line 114, in oracledb.thin_impl.ThinConnImpl._connect_with_address
  File "src/oracledb/impl/thin/protocol.pyx", line 218, in oracledb.thin_impl.Protocol._connect_phase_two
  File "src/oracledb/impl/thin/protocol.pyx", line 336, in oracledb.thin_impl.Protocol._process_message
  File "src/oracledb/impl/thin/protocol.pyx", line 315, in oracledb.thin_impl.Protocol._process_message
  File "src/oracledb/impl/thin/messages.pyx", line 281, in oracledb.thin_impl.Message.process
  File "src/oracledb/impl/thin/messages.pyx", line 2107, in oracledb.thin_impl.ProtocolMessage._process_message
TypeError: cannot convert 'NoneType' object to bytearray

abma avatar Aug 30 '22 08:08 abma

That looks like some unexpected output from the server is occurring. Can you set the environment variable PYO_DEBUG_PACKETS to any value, rerun your script and put the output here? That should help figure things out. If you have a server side sqlnet.ora file, please indicate its contents here as well. Also, can you try with the parmeter disable_oob set to the value True? There have been some issues with out-of-band break detection. Thanks!

anthony-tuininga avatar Aug 30 '22 13:08 anthony-tuininga

@abma Can you get us the trace?

cjbj avatar Aug 31 '22 23:08 cjbj

the oracle listener was configured incorrectly: it had some db server/instance configured which didn't exist.

i can try to reproduce the issue, but this will take a bit.

abma avatar Sep 01 '22 07:09 abma

@abma if you can, we'd love it. Then @anthony-tuininga may be able to squash a bug - even if it is only a missing "can't connect" case that should generate a DPY error.

cjbj avatar Sep 01 '22 08:09 cjbj

If you can indicate what the configuration of the listener was before you fixed it, that would also be helpful, as then we can try to reproduce the problem ourselves. :-)

anthony-tuininga avatar Sep 01 '22 13:09 anthony-tuininga

listener.ora:

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = ORCL.some.domain)
      (ORACLE_HOME = /opt/oracle/product/19c/dbhome_1)
      (SID_NAME = ORCL.some.domain)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = server.some.domain)(PORT = 1521)(IP=V4_ONLY))
    )
  )

and then connect to server.some.domain/ORCL.some.domain

can you provide me a mail address or so, so i can send the trace in private or is this info enough?

abma avatar Sep 01 '22 14:09 abma

You can e-mail me directly at [email protected] (or [email protected]). Both of these e-mail addresses are noted in the Python package information. Thanks!

In the listener.ora configuration above, what was incorrect? What did you have to do to fix it? What error do you get when using the thick driver?

anthony-tuininga avatar Sep 01 '22 14:09 anthony-tuininga

GLOBAL_DBNAME + SID_NAME was incorrect. to fix it i just removed SID_LIST_LISTENER.

i didn't test the thick driver: lsnrctl status says

Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...

abma avatar Sep 01 '22 14:09 abma

Ok. I'll see if I can reproduce here, but the traces would be very helpful if you are able to provide them. Thanks!

anthony-tuininga avatar Sep 01 '22 15:09 anthony-tuininga

Ok. I am able to reproduce here using the contents of the listener.ora you posted. The thick driver gives the following output, for reference:

Traceback (most recent call last):
  File "/home/anthony/git/py-oracledb-oh/t.py", line 9, in <module>
    conn = oracledb.connect(DSN)
  File "/home/anthony/git/py-oracledb-oh/build/lib.linux-x86_64-3.10/oracledb/connection.py", line 1011, in connect
    return conn_class(dsn=dsn, pool=pool, params=params, **kwargs)
  File "/home/anthony/git/py-oracledb-oh/build/lib.linux-x86_64-3.10/oracledb/connection.py", line 137, in __init__
    impl.connect(params_impl, pool_impl)
  File "src/oracledb/impl/thick/connection.pyx", line 385, in oracledb.thick_impl.ThickConnImpl.connect
    _raise_from_odpi()
  File "src/oracledb/impl/thick/utils.pyx", line 410, in oracledb.thick_impl._raise_from_odpi
    _raise_from_info(&error_info)
  File "src/oracledb/impl/thick/utils.pyx", line 400, in oracledb.thick_impl._raise_from_info
    raise exc_type(error)
oracledb.exceptions.OperationalError: ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Additional information: 4775
Additional information: -1450581829
Process ID: 0
Session ID: 0 Serial number: 0

I'll see about adding the necessary code to the thin driver to handle this situation gracefully. Thanks for the report!

anthony-tuininga avatar Sep 02 '22 20:09 anthony-tuininga

I've pushed a patch for this issue. Thanks for your help in resolving it!

anthony-tuininga avatar Sep 02 '22 22:09 anthony-tuininga

Thank you!

abma avatar Sep 05 '22 16:09 abma