mod_python/MySQL error on INSERT with a lot of data: “OperationalError: (2006, 'MySQL server has gone away')”

By : Carver
Source: Stackoverflow.com
Question!

When doing an INSERT with a lot of data, ie:

INSERT INTO table (mediumtext_field) VALUES ('...lots of text here: about 2MB worth...')

MySQL returns

"OperationalError: (2006, 'MySQL server has gone away')"

This is happening within a minute of starting the script, so it is not a timeout issue. Also, mediumtext_field should be able to hold ~16MB of data, so that shouldn't be a problem.

Any ideas what is causing the error or how to work around it?

Some relevant libraries being used: mod_python 3.3.1, MySQL 5.0.51 (on Windows XP SP3, via xampp, details below)

ApacheFriends XAMPP (basic package) version 1.6.5

  • Apache 2.2.6
  • MySQL 5.0.51
  • phpMyAdmin 2.11.3
By : Carver


Answers

check the max_packet setting in your my.cnf file. this determines the largest amount of data you can send to your mysql server in a single statement. exceeding this values results in that error.

By : longneck


First step could be to know what class is leaking. Once you know it, you can find who is increasing the reference: 1. put a breakpoint on the constructor of class that is wrapped by shared_ptr. 2. step in with debugger inside shared_ptr when its increasing the reference count: look at variable pn->pi_->use_count_ Take the address of that variable by evaluating expression (something like this: &this->pn->pi_.use_count_), you will get an address 3. In visual studio debugger, go to Debug->New Breakpoint->New Data Breakpoint... Enter the address of the variable 4. Run the program. Your program will stop every time when some point in the code is increasing and decreasing the reference counter. Then you need to check if those are matching.

By : mariosoft


What I do is wrap the smart pointer with a class that takes FUNCTION and LINE parameters. Increment a count for that function and line every time the constructor is called, and decrement the count every time the destructor is called. then, write a function that dumps the function/line/count information. That tells you where all of your references were created

By : Joe


This video can help you solving your question :)
By: admin