Skip to content

Commit 04c8483

Browse files
author
Aditya A
committed
Bug #30355485 CRASH WHEN DOING ANY OPERATION ON SUB-PARTITIONED TABLE
PROBLEM -------- Removing the ibd file manually after table creation and trying to do a select on the partitioned table after restart caused a debug crash. The debug crash is because we are not cleaning the ha_innopart handle properly in the error path. (when we detect ibd file is missing).In this case it is complaining that bit map allocated for the ha_innopart handler is not freed. FIX --- Properly clear the ha_innopart handler in the error path. RB: 23542 Reviewed-by: Kevin Lewis <[email protected]>
1 parent 07f7899 commit 04c8483

File tree

3 files changed

+49
-8
lines changed

3 files changed

+49
-8
lines changed

mysql-test/r/partition_debug.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,15 @@ SELECT * FROM t1 WHERE b = "Seven";
1414
a b
1515
7 Seven
1616
DROP TABLE t1;
17+
#
18+
# Bug #30355485 CRASH WHEN DOING ANY OPERATION ON SUB-PARTITIONED TABLE
19+
#
20+
CREATE TABLE t1 (a INT, b INT) ENGINE = INNODB
21+
PARTITION BY RANGE(a) SUBPARTITION BY HASH(b)
22+
( PARTITION p0 VALUES LESS THAN (10) (SUBPARTITION s0, SUBPARTITION s1));
23+
# Shut down the server
24+
# Removing test/t1#P#p0#SP#s0.ibd manually
25+
# restart
26+
SELECT * FROM t1;
27+
ERROR 42S02: Table 'test.t1' doesn't exist
28+
DROP TABLE t1;

mysql-test/t/partition_debug.test

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,35 @@ SELECT * FROM t1 WHERE b = "Seven";
1717
SET SESSION debug="-d,partition_fail_index_init";
1818
SELECT * FROM t1 WHERE b = "Seven";
1919
DROP TABLE t1;
20+
21+
22+
--echo #
23+
--echo # Bug #30355485 CRASH WHEN DOING ANY OPERATION ON SUB-PARTITIONED TABLE
24+
--echo #
25+
26+
--let $MYSQLD_DATADIR= `select @@datadir`
27+
CREATE TABLE t1 (a INT, b INT) ENGINE = INNODB
28+
PARTITION BY RANGE(a) SUBPARTITION BY HASH(b)
29+
( PARTITION p0 VALUES LESS THAN (10) (SUBPARTITION s0, SUBPARTITION s1));
30+
31+
--disable_query_log
32+
call mtr.add_suppression("InnoDB: Operating system error number 2 in a file operation");
33+
call mtr.add_suppression("InnoDB: The error means the system cannot find the path specified");
34+
call mtr.add_suppression("InnoDB: Cannot open datafile for read-only:");
35+
call mtr.add_suppression("InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them");
36+
call mtr.add_suppression("InnoDB: Could not find a valid tablespace file for");
37+
call mtr.add_suppression("InnoDB: Ignoring tablespace");
38+
call mtr.add_suppression("InnoDB: Failed to find tablespace for table");
39+
call mtr.add_suppression("InnoDB: Cannot calculate statistics for table");
40+
call mtr.add_suppression("InnoDB: Missing .ibd file for table");
41+
--enable_query_log
42+
43+
--echo # Shut down the server
44+
--source include/shutdown_mysqld.inc
45+
--echo # Removing test/t1#P#p0#SP#s0.ibd manually
46+
--remove_file $MYSQLD_DATADIR/test/t1#P#p0#SP#s0.ibd
47+
--source include/start_mysqld.inc
48+
49+
--error ER_NO_SUCH_TABLE
50+
SELECT * FROM t1;
51+
DROP TABLE t1;

storage/innobase/handler/ha_innopart.cc

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,12 +1113,7 @@ ha_innopart::open(
11131113

11141114
if (!thd_tablespace_op(thd) && no_tablespace) {
11151115
set_my_errno(ENOENT);
1116-
1117-
lock_shared_ha_data();
1118-
m_part_share->close_table_parts();
1119-
unlock_shared_ha_data();
1120-
m_part_share = NULL;
1121-
1116+
close();
11221117
DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
11231118
}
11241119

@@ -1461,8 +1456,10 @@ ha_innopart::close()
14611456

14621457
/* Prevent double close of m_prebuilt->table. The real one was done
14631458
done in m_part_share->close_table_parts(). */
1464-
m_prebuilt->table = NULL;
1465-
row_prebuilt_free(m_prebuilt, FALSE);
1459+
if (m_prebuilt != NULL) {
1460+
m_prebuilt->table = NULL;
1461+
row_prebuilt_free(m_prebuilt, FALSE);
1462+
}
14661463

14671464
if (m_upd_buf != NULL) {
14681465
ut_ad(m_upd_buf_size != 0);

0 commit comments

Comments
 (0)