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
328 stars 66 forks source link

Segmentation fault using soda API on Oracle Linux 9 (aarch64) #72

Closed sdshq closed 1 year ago

sdshq commented 1 year ago
  1. What versions are you using?

Database version: 19c, running on Oracle cloud

platform.platform: Linux-5.15.0-1.43.4.1.el9uek.aarch64-aarch64-with-glibc2.34

sys.maxsize > 2**32: True

platform.python_version: 3.9.10

oracledb.__version__: 1.1.1

Oracle instant client installed: oracle-instantclient19.10-basic-19.10.0.0.0-1.aarch64.rpm

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

A crash: Segmentation fault (core dumped)

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

The example code samples/soda_basic.py crashes when reaching line 125: documents = collection.find().filter({'name': {'$like': 'Ma%'}}).getDocuments()

(venv-oracledb) [opc@instance-20220908-1936 ~]$ python sodabasic.py The key of the new SODA document is: 126EDFEDD0A04F6EBFAA85642294C0B3 Retrieved SODA document dictionary is: {'name': 'Matilda', 'address': {'city': 'Melbourne'}} Retrieved SODA document string is: {"name":"Matilda","address":{"city":"Melbourne"}} Names matching 'Ma%' Segmentation fault (core dumped)_

The virtual environment is clean:

(venv-oracledb) [opc@instance-20220908-1936 ~]$ pip freeze cffi==1.15.1 cryptography==38.0.1 oracledb==1.1.1 pycparser==2.21

The code also crashes in the same manner at line 136: c = collection.find().filter({'address.city': {'$regex': '.*o.*'}}).remove(), if I skip the lines 125~128.

  1. Does your application call init_oracle_client()?

Yes. SODA API requires thick mode, and I'm quite sure that my credentials are correct.

The connection to the DB is also good, since the most part of samples/soda_basic.py works fine.

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

Just the samples/soda_basic.py. I only changed the config_dir for oracledb.init_oracle_client(), and the DB credentials user, password, and dsn for oracledb.connect().

The same code works fine on AMD64 Linux and on Windows, with the corresponding versions of instant clients installed.

I suspect it is something related to the ARM64 version of the instant client.

As shown in the console snippet above, I ran the script on an OCI instance, on which Oracle products are supposed to be well-supported...

cjbj commented 1 year ago

Thanks for the report. Some thoughts:

sdshq commented 1 year ago

Thanks for the report. Some thoughts:

  • 19.10 is 'old' in terms of SODA. It would be interesting to know if 19.10 has the same issue on Linux x64.
  • OL9 hasn't been certified by the DB yet.

I forgot to mention, the DB is running on Oracle cloud, thus it should not be the problem. The most recent client version for aarch64 is 19.10, which is indeed somewhat out dated. I end up with switching to the SQL interface which works great.

Update: a quick study using the same samples/soda_basic.py script suggests that client versions 19.16 and 18.5 on x64 Linux do not have the problem, though v18.5 encounters some encoding issues in the python-oracledb part.

cjbj commented 1 year ago

@sdshq I was able to reproduce the crash only in that specific combination of versions. It is in the layers below python-oracledb so I'll close this issue and followup internally. (In fact I believe it is already fixed). Thanks for reporting it.