Open AntonOvsyannikov opened 2 days ago
Yes, quite likely the well-known statement caching artifact. Try Thin mode, or disable the statement cache by setting its size to 0.
Hopefully you are not dropping & creating tables in production, but just for testing!
The equivalent code without SQLALchemy:
with oracledb.connect(user=un, password=pw, dsn=cs) as connection:
with connection.cursor() as cursor:
cursor.execute('DROP TABLE if exists import_test CASCADE CONSTRAINTS')
cursor.execute('CREATE TABLE import_test (id NUMBER, name CLOB)')
cursor.execute('INSERT INTO import_test (id, name) VALUES (:id, :name)', {'id': '1', 'name': 'vasya'})
cursor.execute('SELECT * FROM import_test FETCH FIRST 100 ROWS ONLY')
for r in cursor.fetchall():
print(r)
cursor.execute('DROP TABLE if exists import_test CASCADE CONSTRAINTS')
cursor.execute('CREATE TABLE import_test (id NUMBER, name VARCHAR2(100))')
cursor.execute('INSERT INTO import_test (id, name) VALUES (:id, :name)', {'id': '1', 'name': 'vasya'})
cursor.execute('SELECT * FROM import_test FETCH FIRST 100 ROWS ONLY')
for r in cursor.fetchall():
print(r)
Gives this in Thin mode:
$ python ~/p/issue424.py
(1, 'vasya')
(1, 'vasya')
and this in Thick mode:
$ python ~/p/issue424.py
Using Thick mode
(1, 'vasya')
Traceback (most recent call last):
File "/Users/cjones/p/issue424.py", line 56, in <module>
for r in cursor.fetchall():
^^^^^^^^^^^^^^^^^
File "/Users/cjones/.pyenv/versions/3.12.7/lib/python3.12/site-packages/oracledb/cursor.py", line 779, in fetchall
row = fetch_next_row(self)
^^^^^^^^^^^^^^^^^^^^
File "src/oracledb/impl/base/cursor.pyx", line 554, in oracledb.base_impl.BaseCursorImpl.fetch_next_row
self._fetch_rows(cursor)
File "src/oracledb/impl/thick/cursor.pyx", line 151, in oracledb.thick_impl.ThickCursorImpl._fetch_rows
_raise_from_odpi()
File "src/oracledb/impl/thick/utils.pyx", line 456, in oracledb.thick_impl._raise_from_odpi
_raise_from_info(&error_info)
File "src/oracledb/impl/thick/utils.pyx", line 446, in oracledb.thick_impl._raise_from_info
raise error.exc_type(error)
oracledb.exceptions.DatabaseError: ORA-03106: fatal two-task communication protocol error
Help: https://docs.oracle.com/error-help/db/ora-03106/
If I set connection.stmtcachesize = 0
and run again in Thick mode there is no issue.
This is really a DB issue outside the scope of python-oracledb, though we have tried to work around it, and have got some DB side improvements made in various scenarios
DPY-5000: internal error: unknown protocol message under very subtile conditions, see comments in code.
DPY-5000: internal error: unknown protocol message under very subtile conditions, see comments in code.
No
output https://gist.github.com/AntonOvsyannikov/4deaea7388d1e1ebc49c9e676a8f10e1
if use
fetch 101 (instead of 100) rows
in second select script works fine https://gist.github.com/AntonOvsyannikov/57bf73afb7a31345cdfb4fc693ab450e see op 58