Bug #30947 BACKUP DATABASE fails if table definitions are larger than 4kbyte
Submitted: 11 Sep 2007 8:07 Modified: 25 Feb 2008 15:52
Reporter: Jan Kneschke Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version:5.2.5 OS:Any
Assigned to: Rafal Somla CPU Architecture:Any

[11 Sep 2007 8:07] Jan Kneschke
Description:
BACKUP DATABASE fails if the table-definitions of the backed up database exceeds 4kbyte in the CREATE TABLE statements:

ERROR 1622 (HY000): Error when saving meta-data of TABLE t1

How to repeat:
$ mysql 
root@127.0.0.1:9306 [(none)]> create database empty;
Query OK, 1 row affected (0.00 sec)

root@127.0.0.1:9306 [(none)]> BACKUP DATABASE empty TO "empty.backup";
+------------------------------+
| Backup Summary               |
+------------------------------+
|  header     =        8 bytes |
|  meta-data  =        2 bytes |
|  data       =        0 bytes |
|               -------------- |
|  total              10 bytes |
+------------------------------+
5 rows in set (1.75 sec)

create a table with more than 4kbyte definitions:

$ cat gen-table.pl
print "CREATE TABLE t1 (\n";
for ($i = 0; $i < 128; $i++) {
        print "col$i BIGINT NOT NULL COMMENT '". "a" x 128  ."',\n";
}
print "col$i BIGINT NOT NULL COMMENT '". "a" x 128  ."'\n";
print ");\n";

$ perl gen-table.pl | mysql empty

$ mysql 
root@127.0.0.1:9306 [(none)]> BACKUP DATABASE empty TO "empty.backup";
ERROR 1622 (HY000): Error when saving meta-data of TABLE t1

Suggested fix:
handle table definitions of any length.
[11 Sep 2007 8:13] Rafal Somla
REFINED PROBLEM DESCRIPTION

In the current version of on-line backup there is a hard-coded limit on the size of a single data chunk in backup image. This limit is currently set to 4K which is way too small as this example shows.

Eventually, chunks should be of unlimited size, but on this stage it should be enough to increase the limit to, say, 2MB. A single chunk should be big enough to fit definitions (CREATE statements) for all tables being backed-up.
[11 Sep 2007 9:15] Rafal Somla
Increasing upper chunk limit to 2MB.
[11 Sep 2007 9: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/34029

ChangeSet@1.2600, 2007-09-11 11:29:35+02:00, rafal@quant.(none) +3 -0
  BUG#30947 (BACKUP DATABASE fails if table definitions are larger than 
  4kbyte):
  
  This is fixed by increasing the limit on single data chunk size to a 
  more realistic value of 2MB. Now backup should work as long as 
  definitions of all tables being backed-up fit into 2MB. The limits are
  configurable through constants defined in backup/stream.h.
[14 Sep 2007 14:33] Chuck Bell
Patch is good to push.
[8 Oct 2007 7:30] Rafal Somla
Pushed into 5.2-backup tree.
[25 Feb 2008 15:52] Paul DuBois
Noted in 6.0.5 changelog.

BACKUP DATABASE crashed if the CREATE TABLE statements for the tables
in a backed-up database exceed 4KB in size. The limit now is 2MB.
[14 Mar 2008 1:28] Paul DuBois
Correction: No changelog entry needed; this bug did not appear in any released version.