executemany with many values (>200) crashes

Bug #663556 reported by Kane Kim
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Connector/Python
Invalid
Undecided
Unassigned

Bug Description

executemany with many values crashes:

Traceback (most recent call last):
  File "/root/test.py", line 40, in insert_entries
    db.cursor().execute(sql)
  File "/root/lib/mysql/connector/cursor.py", line 314, in execute
    res = self.db().protocol.cmd_query(stmt)
  File "/root/lib/mysql/connector/protocol.py", line 136, in deco
    return func(*args, **kwargs)
  File "/root/lib/mysql/connector/protocol.py", line 473, in cmd_query
    self.conn.send(pkt) # Errors handled in _handle_error()
  File "/root/lib/mysql/connector/connection.py", line 78, in send
    raise errors.OperationalError('%s' % e)
OperationalError: [Errno 32] Broken pipe

Revision history for this message
Kane Kim (kane-isturm) wrote :

Forgot to add - happens only in combination with gevent (i think it's mostly used together).

Revision history for this message
Geert JM Vanderkelen (geertjmvdk) wrote :

Hello Kane,

Thanks for opening this bug report.
Could the table and some example data be uploaded?

How are you using gevent with Connector/Python?

Cheers,

Geert

Revision history for this message
Kane Kim (kane-isturm) wrote :

Hello Geert,

It's actually quite easy:
from gevent only:

monkey.patch_all(thread=False)

is used, and then:
db.cursor().executemany("""INSERT INTO user (email, name, list_id, fields) values (%s, %s, %s, %s)""", entries)

so, when there are many rows inserted (looks like it depends on data size, so if inserting long string it would crash earlier), it would crash with above error.

Thanks a lot.

Revision history for this message
tormen (quickhelp) wrote :

Hi Geert,

We ran into similar problems here and it was related to the mysql variable MAX_ALLOWED_PACKET
So we changed our wrapper functions for "insert" to use and respect this value: E.g. chop up the insert into multiple executes.

Knuth

Revision history for this message
Geert JM Vanderkelen (geertjmvdk) wrote :

Thanks Tormen, we'll have to make a better reporting of this problem.
Thing is that the original bug report says it only happens with gevent.

Revision history for this message
Geert JM Vanderkelen (geertjmvdk) wrote :

I think this was also a problem with sending and receiving big packets.
v0.3 should help with that.

Changed in myconnpy:
status: New → Incomplete
Changed in myconnpy:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.