Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
abma opened this issue Aug 30, 2022 · 12 comments
Labels
bug Something isn't working patch available

Comments

@abma
Copy link

abma commented Aug 30, 2022

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 abma added the bug Something isn't working label Aug 30, 2022
@anthony-tuininga
Copy link
Member

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!

@cjbj
Copy link
Member

cjbj commented Aug 31, 2022

@abma Can you get us the trace?

@abma
Copy link
Author

abma commented Sep 1, 2022

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.

@cjbj
Copy link
Member

cjbj commented Sep 1, 2022

@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.

@anthony-tuininga
Copy link
Member

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. :-)

@abma
Copy link
Author

abma commented Sep 1, 2022

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?

@anthony-tuininga
Copy link
Member

You can e-mail me directly at anthony.tuininga@gmail.com (or anthony.tuininga@oracle.com). 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?

@abma
Copy link
Author

abma commented Sep 1, 2022

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...

@anthony-tuininga
Copy link
Member

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
Copy link
Member

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 added a commit that referenced this issue Sep 2, 2022
when connecting to a database that the listener configuration file
states exists but actually doesn't (#51).
@anthony-tuininga
Copy link
Member

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

@abma
Copy link
Author

abma commented Sep 5, 2022

Thank you!

@abma abma closed this as completed Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working patch available
Projects
None yet
Development

No branches or pull requests

3 participants