Bug #35117 Backup: Server crash for backup of CSV engine with CHAR data type
Submitted: 6 Mar 2008 15:48 Modified: 10 Sep 2008 19:52
Reporter: Hema Sridharan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version:mysql-6.0-backup OS:Linux
Assigned to: Jørgen Løland CPU Architecture:Any

[6 Mar 2008 15:48] Hema Sridharan
Description:
1) Create a database.
2)Create table with columns of char data type and with csv as storage engine.
3)Insert some values to table.
4)When you backup the database,the mysql server crashes and loses the connection.

How to repeat:
1) Create database.

mysql> create database csvt;
Query OK, 1 row affected (0.00 sec)

mysql> use csvt;
Database changed

2)Create table t1 with CSV storage engine and one of the columns having char data type.
 
mysql> create table t1(id int not null,name char(20) not null,city varchar(20) not null)engine=csv;
Query OK, 0 rows affected (0.06 sec)

mysql> insert into t1 values(1,'aa','bb'),(2,'aa1','bb1'),(3,'aa2','bb2');
Query OK, 3 rows affected (0.06 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> select * from t1;
+----+------+------+
| id | name | city |
+----+------+------+
|  1 | aa   | bb   |
|  2 | aa1  | bb1  |
|  3 | aa2  | bb2  |
+----+------+------+
3 rows in set (0.01 sec)

3)I backup the database.

mysql> backup database csvt to '/data2/heman/backup_dmp/csvt3';
ERROR 2013 (HY000): Lost connection to MySQL server during query
[6 Mar 2008 15:56] MySQL Verification Team
Thank you for the bug report.

[miguel@mira dbs]$ 6.0b/bin/mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 6.0.5-alpha-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database csvt;
Query OK, 1 row affected (0.00 sec)

mysql> use csvt;
Database changed
mysql> create table t1(id int not null,name char(20) not null,city varchar(20) not
    -> null)engine=csv;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values(1,'aa','bb'),(2,'aa1','bb1'),(3,'aa2','bb2');
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> select * from t1;
+----+------+------+
| id | name | city |
+----+------+------+
|  1 | aa   | bb   | 
|  2 | aa1  | bb1  | 
|  3 | aa2  | bb2  | 
+----+------+------+
3 rows in set (0.00 sec)

mysql> backup database csvt to '/home/miguel/dbs/bk';          
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>
[13 Mar 2008 15:23] Hema Sridharan
Stack Trace
===========
ndbdev@ndb16:/data2/hemanew_clone/mysql-6.0-backup/extra> ./resolve_stack_dump -s /tmp/mysqld.sym -n mysqld.stack
0x87a6de safe_print_str + 278
0x87a725 print_stacktrace + 21
0x6dc09b handle_segfault + 595
0x3f4080c430 _end + 1060661000
0x3f3ff2e21d _end + 1051362549
0x3f3ff2fa1e _end + 1051368694
0x3f3ff27ae1 _end + 1051336121
0x72d377 _Z18close_thread_tableP3THDPP8st_table + 171
0x72cf17 _Z30close_cached_connection_tablesP3THDbP19st_mysql_lex_stringb + 1219
0x72d260 _Z19close_thread_tablesP3THD + 726
0xcb5589 backup_thread_for_locking + 991
0x3f4080610a _end + 1060635618
0x3f3ffc68b3 _end + 1051986827
[12 Aug 2008 11:37] Jørgen Løland
Some analysis:

* The bug is that in field.cc:6266 (Field_string::store), an assert that checks that table->in_use is the same thread as _current_thd(). In this case, table->in_use is the locking thread spawned by backup, not the backup thread that currently tries to read the record
* This is related to default driver. The bug is also present if falcon engine is used with partitioned tables [1] (see bug#38426), but not with innodb or myisam. It is not present for memory engine either, but that's likely because memory engine does not use field class to read.

Alternative solution: 
1. Somehow reset table->in_use to the backup thread before reading the records.
2. Read using the thread that locked the table

[1]
create table t1(id int not null,name char(20) not null,city varchar(20) not null) engine=Falcon;
alter table t1 PARTITION BY HASH (id);
[12 Aug 2008 12:02] Øystein Grøvlen
This looks like bug#36792 which I worked on for a while until I determined that it was a duplicate of bug#33566.
[12 Aug 2008 15:16] Chuck Bell
Approved pending addition of:

--source include/have_falcon.inc
[18 Aug 2008 9:43] Øystein Grøvlen
New patch looks good.  Approved to push.
[10 Sep 2008 13:18] Øystein Grøvlen
Pushed to 6.0.7.
[10 Sep 2008 15:24] Bugs System
Pushed into 6.0.7-alpha  (revid:jorgen.loland@sun.com-20080818082556-mwzfrfaarth2zprz) (version source revid:jorgen.loland@sun.com-20080818082556-mwzfrfaarth2zprz) (pib:3)
[10 Sep 2008 19:52] Paul DuBois
Noted in 6.0.7 changelog.

CSV tables with CHAR columns caused BACKUP DATABASE to produce a
server crash.
[11 Sep 2008 22:38] 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/53891

2693 He Zhenxing	2008-09-12 [merge]
      Merge 6.0 main -> 6.0-rpl
[14 Sep 2008 2:52] Bugs System
Pushed into 6.0.7-alpha  (revid:jorgen.loland@sun.com-20080818082556-mwzfrfaarth2zprz) (version source revid:sven@mysql.com-20080818175803-c1nutd5773r6b4gd) (pib:3)
[16 Sep 2008 9:07] Bugs System
Pushed into 6.0.8-alpha  (revid:jorgen.loland@sun.com-20080818082556-mwzfrfaarth2zprz) (version source revid:konstantin@mysql.com-20080915203725-7s0qc6tbo295pp3w) (pib:3)
[23 Sep 2008 11:13] 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/54481

2694 He Zhenxing	2008-09-22 [merge]
      Auto Merge