Bug #58887 Server not throwing "Packet too large" error if max_allowed_packet >= 16M
Submitted: 12 Dec 2010 4:06 Modified: 12 Jan 2011 18:14
Reporter: Matt Wood Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.1.52, 5.1.54 OS:Linux
Assigned to: Dmitry Shulga CPU Architecture:Any
Tags: max_allowed_packet, regression
Triage: Triaged: D3 (Medium)

[12 Dec 2010 4:06] Matt Wood
Description:
In MySQL Server 5.1.52 a packet is not rejected if it is over the server's max_allowed_packet bytes and max_allowed_packet is set to 16M or higher.

If the server's max_allowed_packet is set to anything lower than 16M it behaves correctly.

This was not an issue in 5.1.51

How to repeat:
First you need a large packet, it doesn't need to be anything valid since it doesn't matter if MySQL actually evaluates it. We expect it to reject it outright anyway. I used this perl script to build a 17mb file:

---

#!/usr/bin/perl
open OUTFILE, '>', 'big_packet.sql' or die $!;
print OUTFILE ('1' x 17825792);
close OUTFILE;

---

Configure your server to have a max_allowed_packet of 16M. Then have the command line client send over the contents of the generated file:

mysql -u root -p < big_packet.sql

You'll have to successfully authenticate for MySQL to look at the packet.

On 5.1.51 I get this response:

---

ERROR 1153 (08S01) at line 1: Got a packet bigger than 'max_allowed_packet' bytes

---

On 5.1.52 I get this response:

---

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '11111111111111111111111111111111111111111111111111111111111111111111111111111111' at line 1

---

On 5.1.52 MySQL seems to be evaluating it, when I think it should just be rejecting it.

This is just my dumb test case, when I replace the text file filled with 1s with a huge bulk insert, 5.1.52 accepts and inserts the rows but 5.1.51 does not.
[12 Dec 2010 16:26] Valeriy Kravchuk
Verified with 5.1.54:

openxs@ubuntu:/home2/openxs/dbs/5.1$ bin/mysql --no-defaults -uroot < /tmp/big.sql 
ERROR 1153 (08S01) at line 1: Got a packet bigger than 'max_allowed_packet' bytes

This is what we get with default value of max_allowed_packet. Now:

openxs@ubuntu:/home2/openxs/dbs/5.1$ bin/mysql --version
bin/mysql  Ver 14.14 Distrib 5.1.54, for pc-linux-gnu (i686) using readline 5.1
openxs@ubuntu:/home2/openxs/dbs/5.1$ bin/mysqladmin --no-defaults -uroot shutdown
openxs@ubuntu:/home2/openxs/dbs/5.1$ bin/mysqld_safe --no-defaults --max_allowed_packet=16M &
[1] 3274
openxs@ubuntu:/home2/openxs/dbs/5.1$ 101212 18:23:27 mysqld_safe Logging to '/home2/openxs/dbs/5.1/var/ubuntu.err'.
101212 18:23:28 mysqld_safe Starting mysqld daemon with databases from /home2/openxs/dbs/5.1/var

openxs@ubuntu:/home2/openxs/dbs/5.1$ bin/mysql --no-defaults -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.54-valgrind-max-debug Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'max_all%';
+--------------------+----------+
| Variable_name      | Value    |
+--------------------+----------+
| max_allowed_packet | 16777216 |
+--------------------+----------+
1 row in set (0.00 sec)

mysql> exit
Bye
openxs@ubuntu:/home2/openxs/dbs/5.1$ bin/mysql --no-defaults -uroot < /tmp/big.sql 
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '11111111111111111111111111111111111111111111111111111111111111111111111111111111' at line 1
[30 Dec 2010 9:45] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/127706

3531 Dmitry Shulga	2010-12-30
      Fixed Bug#58887	- server not throwing "Packet too large" error
      if max_allowed_packet >= 16M.
      
      This bug was introduced by patch for bug#42503.
      
      This patch restores behaviour that there was before patch
      for bug#42503 was applied.
     @ sql/net_serv.cc
        Restored original right condition.
[11 Jan 2011 10:46] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/128408

3540 Dmitry Shulga	2011-01-11
      Fixed Bug#58887	- server not throwing "Packet too large" error
      if max_allowed_packet >= 16M.
      
      This bug was introduced by patch for bug#42503.
      
      This patch restores behaviour that there was before patch
      for bug#42503 was applied.
     @ sql/net_serv.cc
        Restored original right condition.
[11 Jan 2011 15:19] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/128439

3542 Dmitry Shulga	2011-01-11
      Fixed Bug#58887	- server not throwing "Packet too large" error
      if max_allowed_packet >= 16M.
      
      This bug was introduced by patch for bug#42503.
      
      This patch restores behaviour that there was before patch
      for bug#42503 was applied.
     @ sql/net_serv.cc
        Restored original right condition.
[11 Jan 2011 15:30] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/128440

3236 Dmitry Shulga	2011-01-11 [merge]
      Auto-merge mysql-5.1 -> mysql-5.5 for bug#58887.
[11 Jan 2011 15:37] Bugs System
Pushed into mysql-5.1 5.1.55 (revid:dmitry.shulga@oracle.com-20110111151825-d376jh0jefmsdslw) (version source revid:dmitry.shulga@oracle.com-20110111151825-d376jh0jefmsdslw) (merge vers: 5.1.55) (pib:24)
[11 Jan 2011 15:37] Bugs System
Pushed into mysql-trunk 5.6.2 (revid:dmitry.shulga@oracle.com-20110111153355-uvff16i445mk2spu) (version source revid:dmitry.shulga@oracle.com-20110111153355-uvff16i445mk2spu) (merge vers: 5.6.2) (pib:24)
[11 Jan 2011 15:38] Bugs System
Pushed into mysql-5.5 5.5.9 (revid:dmitry.shulga@oracle.com-20110111152631-jezu2dbglg05g6ff) (version source revid:dmitry.shulga@oracle.com-20110111152631-jezu2dbglg05g6ff) (merge vers: 5.5.9) (pib:24)
[11 Jan 2011 15:38] Dmitry Shulga
Pushed into mysql-5.1, mysql-5.5, mysql-trunk.
[12 Jan 2011 18:14] Paul Dubois
Noted in 5.1.55, 5.5.9, 5.6.2 changelogs.

If max_allowed_packet was set larger than 16MB, the server failed to
reject too-large packets with "Packet too large" errors.