Merge lp:~laurynas-biveinis/percona-server/bug1204871 into lp:percona-server/5.6

Proposed by Laurynas Biveinis
Status: Merged
Approved by: Laurynas Biveinis
Approved revision: no longer in the source branch.
Merged at revision: 527
Proposed branch: lp:~laurynas-biveinis/percona-server/bug1204871
Merge into: lp:percona-server/5.6
Diff against target: 87 lines (+35/-2)
5 files modified
Percona-Server/mysql-test/suite/parts/r/partition_bug71270.result (+8/-0)
Percona-Server/mysql-test/suite/parts/t/partition_bug71270.test (+21/-0)
Percona-Server/sql/ha_partition.cc (+1/-0)
Percona-Server/sql/sql_class.h (+1/-1)
Percona-Server/sql/sql_insert.cc (+4/-1)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/bug1204871
Reviewer Review Type Date Requested Status
Vlad Lesin (community) g2 Approve
Review via email: mp+200529@code.launchpad.net

Description of the change

No BT or ST but part of TokuDB QA.

Fix bug 1204871 (abort in ha_partition::end_bulk_insert |
sql/ha_partition.cc:4438: virtual int ha_partition::end_bulk_insert():
Assertion `0' failed. (sig6)) /
http://bugs.mysql.com/bug.php?id=71270.

A debug server build will crash if, while performing a bulk insert to
a partitioned table, one of the partitions will return a failure for
end_bulk_insert handler call.

The crash happens because the failing ha_partition::end_bulk_insert()
call will clear the m_bulk_insert_started bitmap before returning the
failure to the caller. The caller will handle the failure, and at one
point it will call select_insert::abort_result_set(), which will
attempt end_bulk_insert again, which will hit DBUG_ASSERT(0) because
m_bulk_insert_started is cleared.

Fix by resetting THD::bulk_insert_started_flag on end bulk insert
handler calls. Add an error-injecting testcase
parts/partition_bug71270.

http://jenkins.percona.com/job/percona-server-5.6-param/471/

To post a comment you must log in.
Revision history for this message
Vlad Lesin (vlad-lesin) :
review: Approve (g2)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'Percona-Server/mysql-test/suite/parts/r/partition_bug71270.result'
2--- Percona-Server/mysql-test/suite/parts/r/partition_bug71270.result 1970-01-01 00:00:00 +0000
3+++ Percona-Server/mysql-test/suite/parts/r/partition_bug71270.result 2014-01-06 13:21:36 +0000
4@@ -0,0 +1,8 @@
5+SET debug="+d,ha_partition_end_bulk_insert_fail";
6+CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
7+INSERT INTO t1 VALUES (1),(2),(3);
8+CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB PARTITION BY HASH (id) PARTITIONS 2;
9+INSERT INTO t2 SELECT * FROM t1;
10+ERROR HY000: Got error 1 from storage engine
11+DROP TABLE t1, t2;
12+SET debug=default;
13
14=== added file 'Percona-Server/mysql-test/suite/parts/t/partition_bug71270.test'
15--- Percona-Server/mysql-test/suite/parts/t/partition_bug71270.test 1970-01-01 00:00:00 +0000
16+++ Percona-Server/mysql-test/suite/parts/t/partition_bug71270.test 2014-01-06 13:21:36 +0000
17@@ -0,0 +1,21 @@
18+#
19+# Testcase for http://bugs.mysql.com/bug.php?id=71270
20+# (Failures to end bulk insert for partitioned tables handled incorrectly)
21+#
22+--source include/have_debug.inc
23+--source include/have_innodb.inc
24+--source include/have_partition.inc
25+
26+SET debug="+d,ha_partition_end_bulk_insert_fail";
27+
28+CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
29+INSERT INTO t1 VALUES (1),(2),(3);
30+
31+CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB PARTITION BY HASH (id) PARTITIONS 2;
32+
33+--error ER_GET_ERRNO
34+INSERT INTO t2 SELECT * FROM t1;
35+
36+DROP TABLE t1, t2;
37+
38+SET debug=default;
39
40=== modified file 'Percona-Server/sql/ha_partition.cc'
41--- Percona-Server/sql/ha_partition.cc 2013-12-05 17:23:10 +0000
42+++ Percona-Server/sql/ha_partition.cc 2014-01-06 13:21:36 +0000
43@@ -4495,6 +4495,7 @@
44 error= tmp;
45 }
46 bitmap_clear_all(&m_bulk_insert_started);
47+ DBUG_EXECUTE_IF("ha_partition_end_bulk_insert_fail", error= 1;);
48 DBUG_RETURN(error);
49 }
50
51
52=== modified file 'Percona-Server/sql/sql_class.h'
53--- Percona-Server/sql/sql_class.h 2013-12-16 08:45:31 +0000
54+++ Percona-Server/sql/sql_class.h 2014-01-06 13:21:36 +0000
55@@ -4628,7 +4628,7 @@
56 */
57 List<Item> *fields;
58 protected:
59- /// ha_start_bulk_insert has been called. Never cleared.
60+ /// ha_start_bulk_insert has been called.
61 bool bulk_insert_started;
62 public:
63 ulonglong autoinc_value_of_last_inserted_row; // autogenerated or not
64
65=== modified file 'Percona-Server/sql/sql_insert.cc'
66--- Percona-Server/sql/sql_insert.cc 2013-12-16 08:45:31 +0000
67+++ Percona-Server/sql/sql_insert.cc 2014-01-06 13:21:36 +0000
68@@ -3793,6 +3793,7 @@
69
70 error= (bulk_insert_started ?
71 table->file->ha_end_bulk_insert() : 0);
72+ bulk_insert_started= false;
73 if (!error && thd->is_error())
74 error= thd->get_stmt_da()->sql_errno();
75
76@@ -3884,8 +3885,10 @@
77 if tables are not locked yet (bulk insert is not started yet
78 in this case).
79 */
80- if (bulk_insert_started)
81+ if (bulk_insert_started) {
82 table->file->ha_end_bulk_insert();
83+ bulk_insert_started= false;
84+ }
85
86 /*
87 If at least one row has been inserted/modified and will stay in

Subscribers

People subscribed via source and target branches