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

MySQL MariaDB ODBC memory allocation error on huge execute #721

Closed
pickfire opened this issue Mar 3, 2020 · 8 comments
Closed

MySQL MariaDB ODBC memory allocation error on huge execute #721

pickfire opened this issue Mar 3, 2020 · 8 comments

Comments

@pickfire
Copy link

pickfire commented Mar 3, 2020

Please first make sure you have looked at:

Environment

To diagnose, we usually need to know the following, including version numbers. On Windows, be
sure to specify 32-bit Python or 64-bit:

Issue

Often it is easiest to describe your issue as "expected behavior" and "observed behavior".

When execute in bulk (generating our own bulk upsert statement), after more than 5000 batches being executed consequently, it shows:

pyodbc.OperationalError: ('HY001', '[HY001] [ma-3.1.5][5.7.12]Memory allocation error (0) (SQLPutData)')

executemany does not have this issue but is very, very, very, very slow compared to this method.

@gordthompson
Copy link
Collaborator

Are you saying that after you execute 5000 huge upserts you get the error (suggesting a memory leak), or are you saying that a huge upsert of more than 5000 rows produces the error the first time you try it?

@pickfire
Copy link
Author

pickfire commented Mar 3, 2020

@gordthompson After more than 5000 rows are being upsert with 1000 each round so sixth time (> 5000), or somewhere around there. I even tweak to use 1200 so after the fifth time (> 4800) it also breaks. The total data that is around 6500 rows.

After I try this, even the normal slow executemany breaks too.

@v-chojas
Copy link
Contributor

v-chojas commented Mar 3, 2020

After I try this, even the normal slow executemany breaks too.

It seems like this may be a bug in the ODBC driver.

@pickfire
Copy link
Author

pickfire commented Mar 4, 2020

But it used to work though? So maybe I should try the MySQL own ODBC driver?

@keitherskine
Copy link
Collaborator

You could perhaps try taking pyodbc out of the picture by running your SQL queries through the isql utility. See if you still get a memory allocation error.

@pickfire
Copy link
Author

pickfire commented Mar 4, 2020

@keitherskine There is no issue when using it with isql directly with all the batches of data, of course I converted it to string without the ? beforehand.

@pickfire
Copy link
Author

pickfire commented Mar 4, 2020

Oh, looks like not using the ? works but I am not sure if this is secure though, even though this is used internally.

@gordthompson
Copy link
Collaborator

Closed due to inactivity. Feel free to re-open with current information if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants