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

Strange DPY-5002 error with executemany batcherrors #262

Closed
anthony-tuininga opened this issue Dec 5, 2023 Discussed in #261 · 3 comments
Closed

Strange DPY-5002 error with executemany batcherrors #262

anthony-tuininga opened this issue Dec 5, 2023 Discussed in #261 · 3 comments
Labels
bug Something isn't working patch available

Comments

@anthony-tuininga
Copy link
Member

Discussed in #261

Originally posted by vinidmpereira December 4, 2023
Hello all,

I'm currently having a weird problem in Airflow using OracleHook, i know this forum pertains to oracledb but i think this is where i need help.

So i've been writing a large migrating script to unify multiple similar databases into a singular one, and in one of the migrations i've been hit with:

oracledb.exceptions.InternalError: DPY-5002: internal error: read integer of length 3 when expecting integer of no more than length 2

And this error only occurs in one of the 40+ databases i'm currently migrating, it's such a weird error and i can't find anything about this specific error, theres another topic where someone is currently having a similar mistake but with a DPY-5003 error, and i don't know if they are connected.

@anthony-tuininga anthony-tuininga added the bug Something isn't working label Dec 5, 2023
@anthony-tuininga
Copy link
Member Author

anthony-tuininga commented Dec 5, 2023

I was table to replicate this. The protocol only allows for 65535 errors. If you exceed this value you get this error in thin mode. In thick mode you get invalid results (the number of batch errors is simply truncated by looking at the lowest 16 bits of the value) -- except when the number of batch errors is a multiple of 65535, in which case you get ORA-38902: errors in array DML exceed 65535. As such, this is a bug in the database and will need to be fixed there. I will, however, correct the strange error in thin mode and ensure a more meaningful error is raised!

The issue can be avoided by always ensuring that you never send more than 65535 rows to the database at a time when using batch errors -- or by ensuring that the number of errors never exceeds 65535 in some other fashion.

A simple test case that demonstrates the problem:

create table issue_262 (
    IntCol number(9) not null,
    StringCol varchar2(50) not null,
    constraint TestTempTable_pk primary key (IntCol)
);

with this Python script:

import oracledb

# oracledb.init_oracle_client()

conn = oracledb.connect("user/password@host/service_name")
cursor = conn.cursor()

data = [(1, None)] * (65537)
cursor.executemany("insert into issue_262 values (:1, :2)", data,
                   batcherrors=True)
errors = cursor.getbatcherrors()
print("found", len(errors), "batch errors")

@anthony-tuininga
Copy link
Member Author

I have pushed a patch that should correct this bug. If you are able to build from source you can verify that it works for you.

@anthony-tuininga
Copy link
Member Author

The patch has been included in version 2.0.0 which was just released.

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

1 participant