Bug #1400 BACKUP TABLE should flush the table being backed up
Submitted: 25 Sep 2003 11:44 Modified: 17 Oct 2003 9:52
Reporter: Indrek Siitan Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S2 (Serious)
Version:4.0, 4.1 OS:Any (any)
Assigned to: Sergei Golubchik CPU Architecture:Any

[25 Sep 2003 11:44] Indrek Siitan
Description:
BACKUP TABLE should flush the table to disk before copying the files. Follows
a simple case to prove it's not done correctly currently.

How to repeat:
mysql> create table btest ( id int not null auto_increment primary key );
Query OK, 0 rows affected (0.00 sec)

mysql> insert into btest values (null); 
Query OK, 1 row affected (0.00 sec)

mysql> insert into btest values (null);
Query OK, 1 row affected (0.00 sec)

mysql> insert into btest values (null);
Query OK, 1 row affected (0.00 sec)

mysql> insert into btest values (null);
Query OK, 1 row affected (0.00 sec)

mysql> insert into btest values (null);
Query OK, 1 row affected (0.00 sec)

mysql> select * from btest;
+----+
| id |
+----+
|  1 |
|  2 |
|  3 |
|  4 |
|  5 |
+----+
5 rows in set (0.00 sec)

mysql> delete from btest where id in (4,5);
Query OK, 2 rows affected (0.00 sec)

mysql> backup table btest to '/tmp';
+-----------+--------+----------+----------+
| Table     | Op     | Msg_type | Msg_text |
+-----------+--------+----------+----------+
| bug.btest | backup | status   | OK       |
+-----------+--------+----------+----------+
1 row in set (0.00 sec)

mysql> drop table btest;
Query OK, 0 rows affected (0.01 sec)

mysql> flush tables;
Query OK, 0 rows affected (0.00 sec)

mysql> restore table btest from '/tmp';+-----------+---------+----------
+-------------------------------------------------------------------------------+
| Table     | Op      | Msg_type | Msg_text                                                                      |
+-----------+---------+----------
+-------------------------------------------------------------------------------+
| bug.btest | repair  | error    | Couldn't fix table with quick recovery: Found wrong number of 
deleted records |
| bug.btest | repair  | error    | Run recovery again without -q                                                 |
| bug.btest | restore | status   | OK                                                                            |
+-----------+---------+----------
+-------------------------------------------------------------------------------+
3 rows in set (0.01 sec)

mysql> select * from btest;
+----+
| id |
+----+
|  1 |
|  2 |
|  3 |
+----+
3 rows in set (0.00 sec)

mysql> insert into btest values (null);
Query OK, 1 row affected (0.00 sec)

mysql> select * from btest;
+----+
| id |
+----+
|  1 |
|  2 |
|  3 |
|  4 |   <-- should be 6!
+----+
4 rows in set (0.00 sec)
[29 Sep 2003 2:36] Sergei Golubchik
no, it has nothing to do with flush.
unfortunately :(
[17 Oct 2003 9:52] Sergei Golubchik
The problem is that BACKUP TABLE does not back up MYI header.
Instead of changing the behaviour of BACKUP TABLE we'll create online backup feature that will fix this problem too