Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#136 _mysql_exceptions.OperationalError: (2020, "Got packet bigge

MySQLdb-1.2
closed
Andy Dustman
MySQLdb (285)
5
2012-09-19
2005-05-11
Martin Mokrejs
No

Hi,
it seems to me that either _mysql or mysqldb somehow
uses small max_allowed_packet variable. At least this
is where the error message points to. my.cnf files on
both, server and client set the variable to 1GB. They
are properly honored by mysql and mysqld. I point
mysqldb to read the .my.cnf file and in principle have
no reason to think it ignores it.

However, I perform very small select statement and it
dies with the above message. It works for other rows
and the difference is that this row contains over 8k
characters in BLOB. That's not much at all and even
with often default max_allowed_packet=1M this should
still work fine.

I suspect it's a bug in the wrappers. I have tested
mysql-4.0.24, 4.1.11, all on 2 machines running linux.
No luck.

$ cat >> bug.py
from MySQLdb import connect, DatabaseError, cursors
_c = connect(read_default_file =
"/home/mmokrejs/.my.cnf", read_default_group = 'test')
_c.query("show variables")
s = _c.store_result()
print s.num_rows()
_count = s.num_rows()
_index = 0
while _count != _index:
print s.row_tell()
print s.fetch_row()
_index += 1

The output is:

184
0
(('back_log', '100'),)
4
(('basedir',
'/usr/local/mysql-standard-4.1.11-pc-linux-gnu-i686/'),)
-1431655754
(('binlog_cache_size', '32768'),)
16
(('bulk_insert_buffer_size', '8388608'),)
-1431655744
(('character_set_client', 'latin1'),)
26
(('character_set_connection', 'latin1'),)
-1431655734
(('character_set_database', 'latin1'),)
1431655802
(('character_set_results', 'latin1'),)
42
(('character_set_server', 'latin1'),)
1431655812
(('character_set_system', 'utf8'),)
-1431655714

Maybe this would point to the problem with my select
statement and explain why it looks like the
max_allowed_packet problem?

Discussion

<< < 1 2 3 4 > >> (Page 3 of 4)
  • Andy Dustman
    Andy Dustman
    2005-05-12

    Logged In: YES
    user_id=71372

    See if 1.2.1c3 fixes your build problems. row_tell() and
    row_seek() raise ProgrammingError if you used conn.use_result().

     
  • Logged In: NO

    With 1.2.1c3 I do not get ProgrammingError, but the code

    from MySQLdb import connect, DatabaseError, cursors
    _c = connect(read_default_file = "/home/mmokrejs/.my.cnf")
    _c.query("show variables")
    s = _c.use_result()
    print s.num_rows()

    $ python bug2.py && echo passed
    0
    passed
    $

     
  • Logged In: NO

    Sorry for the previous post, it did not contain row_tell()
    anymore. Here it is again for 1.2.1c3.

      1 from MySQLdb import connect, DatabaseError, cursors
      2 _c = connect(read_default_file =
    

    "/home/mmokrejs/.my.cnf")
    3 _c.query("show variables")
    4 s = _c.use_result()
    5 print s.num_rows()
    6 _count = s.num_rows()
    7 _index = 0
    8 while _count != _index:
    9 print s.row_tell()
    10 print s.fetch_row()
    11 _index += 1

    $ python bug2.py && echo passed
    0
    passed
    $

     
  • Logged In: NO

    I still can't build 1.2.1c3 using brokem mysql_config:

    running build_ext
    building '_mysql' extension
    creating build/temp.linux-i686-2.3
    i686-pc-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG
    -fPIC -I/usr/include/python2.3 -c _mysql.c -o
    build/temp.linux-i686-2.3/_mysql.o
    -I'/usr/local/mysql-max-4.0.15-pc-linux-i686/include'
    _mysql.c:41:19: mysql.h: No such file or directory
    _mysql.c:42:26: mysqld_error.h: No such file or directory
    _mysql.c:43:20: errmsg.h: No such file or directory

     
  • Andy Dustman
    Andy Dustman
    2005-05-12

    Logged In: YES
    user_id=71372

    It is never reaching s.row_tell() in your latest example. I
    suppose I should make .num_rows() raise ProgrammingError as
    well for the .use_result() case.

    Take a look at setup.py and see if you see something I
    don't. It ought to be removing those quotes, unless maybe
    they aren't normal quotes. They look normal. I do not have a
    system I am able to replicate this on.

     
  • Andy Dustman
    Andy Dustman
    2005-05-12

    Logged In: YES
    user_id=71372

    Scratch part of that last comment: .num_rows() does return
    a valid value in the .use_result() case, but only after you
    have read the entire result set, which makes it not terribly
    useful, but it is what it is.

     
  • Martin Mokrejs
    Martin Mokrejs
    2005-05-12

    Logged In: YES
    user_id=696559

    You should call --cflags instead of --include

    $ find /usr/local/mysql* -name mysql_config | while read f;
    do $f --cflags; done
    -I/usr/local/mysql-debug-4.1.11-pc-linux-gnu-i686/include
    -mcpu=pentiumpro
    -I'/usr/local/mysql-max-4.0.15-pc-linux-i686/include'
    -I/usr/local/mysql-max-4.0.16-pc-linux-i686/include
    -mpentiumpro -DBIG_TABLES
    -I/usr/local/mysql-max-4.0.17-pc-linux-i686/include
    -mpentiumpro -DBIG_TABLES
    -I/usr/local/mysql-max-4.0.18-pc-linux-i686/include
    -mpentiumpro -DBIG_TABLES
    -I/usr/local/mysql-max-4.0.21-pc-linux-i686/include
    -mpentiumpro -DBIG_TABLES
    -I/usr/local/mysql-max-4.0.22-pc-linux-i686/include
    -mpentiumpro -DBIG_TABLES
    -I/usr/local/mysql-standard-4.0.22-pc-linux-i686-icc-glibc23/include
    -unroll2 -ip -mp -no-gcc -restrict
    -I/usr/local/mysql-standard-4.0.24-pc-linux-gnu-i686/include
    -mcpu=pentiumpro
    -I/usr/local/mysql-standard-4.1.10-pc-linux-gnu-i686/include
    -mcpu=pentiumpro
    -I/usr/local/mysql-standard-4.1.10a-pc-linux-gnu-i686/include
    -mcpu=pentiumpro
    -I/usr/local/mysql-standard-4.1.11-pc-linux-gnu-i686/include
    -mcpu=pentiumpro
    -I/usr/local/mysql-standard-4.1.11-unknown-linux-gnu-x86_64-icc-glibc23/include
    -ip -ip_no_inlining
    -I/usr/local/mysql-standard-4.1.6-gamma-pc-linux-i686/include
    -mcpu=pentiumpro
    -I/usr/local/mysql-standard-4.1.7-pc-linux-i686/include
    -mcpu=pentiumpro
    -I/usr/local/mysql-standard-4.1.8-pc-linux-i686/include
    -mcpu=pentiumpro
    -I/usr/local/mysql-standard-4.1.9-pc-linux-gnu-i686/include
    -mcpu=pentiumpro
    $

     
  • Andy Dustman
    Andy Dustman
    2005-05-12

    Logged In: YES
    user_id=71372

    Does --include just not work on the older versions, or does
    it return bad data?

     
  • Martin Mokrejs
    Martin Mokrejs
    2005-05-12

    Logged In: YES
    user_id=696559

    Including the patch. The dummy() function might be removed,
    but am still a beginner programmer. :(

    To answer your question, you get no data back on STDOUT, on
    STDERR is the usage message:

    find /usr/local/mysql* -name mysql_config | while read f;

    do $f --include; done
    -I/usr/local/mysql-debug-4.1.11-pc-linux-gnu-i686/include
    Usage:
    /usr/local/mysql-max-4.0.15-pc-linux-i686/bin/mysql_config
    [OPTIONS]
    Options:
    --cflags
    [-I'/usr/local/mysql-max-4.0.15-pc-linux-i686/include']
    --libs
    [-L'/usr/local/mysql-max-4.0.15-pc-linux-i686/lib'
    -lmysqlclient -lz -lcrypt -lnsl -lm -lc -lnss_files
    -lnss_dns -lresolv -lc -lnss_files -lnss_dns -lresolv]

    --socket [/tmp/mysql.sock]
    --port [3306]
    --version [4.0.15]
    --libmysqld-libs
    -L'/usr/local/mysql-max-4.0.15-pc-linux-i686/lib' -lmysqld
    -lpthread -lz -lcrypt -lnsl -lm -lpthread -lc -lnss_files
    -lnss_dns -lresolv -lc -lnss_files -lnss_dns -lresolv -lrt

    -I/usr/local/mysql-max-4.0.16-pc-linux-i686/include
    -I/usr/local/mysql-max-4.0.17-pc-linux-i686/include
    -I/usr/local/mysql-max-4.0.18-pc-linux-i686/include
    -I/usr/local/mysql-max-4.0.21-pc-linux-i686/include
    -I/usr/local/mysql-max-4.0.22-pc-linux-i686/include
    -I/usr/local/mysql-standard-4.0.22-pc-linux-i686-icc-glibc23/include
    -I/usr/local/mysql-standard-4.0.24-pc-linux-gnu-i686/include
    -I/usr/local/mysql-standard-4.1.10-pc-linux-gnu-i686/include
    -I/usr/local/mysql-standard-4.1.10a-pc-linux-gnu-i686/include
    -I/usr/local/mysql-standard-4.1.11-pc-linux-gnu-i686/include
    -I/usr/local/mysql-standard-4.1.11-unknown-linux-gnu-x86_64-icc-glibc23/include
    -I/usr/local/mysql-standard-4.1.6-gamma-pc-linux-i686/include
    -I/usr/local/mysql-standard-4.1.7-pc-linux-i686/include
    -I/usr/local/mysql-standard-4.1.8-pc-linux-i686/include
    -I/usr/local/mysql-standard-4.1.9-pc-linux-gnu-i686/include

     
  • Martin Mokrejs
    Martin Mokrejs
    2005-05-12

    MySQL-python-1.2.1c3/setup.py.patch

     
    Attachments
<< < 1 2 3 4 > >> (Page 3 of 4)