| 1 |
# |
| 2 |
# Bug#49907: ALTER TABLE ... TRUNCATE PARTITION |
| 3 |
# does not wait for locks on the table |
| 4 |
# |
| 5 |
CREATE TABLE t1 (a INT) |
| 6 |
ENGINE = InnoDB |
| 7 |
PARTITION BY RANGE (a) |
| 8 |
(PARTITION p0 VALUES LESS THAN (15), |
| 9 |
PARTITION pMax VALUES LESS THAN MAXVALUE); |
| 10 |
INSERT INTO t1 VALUES (1), (11), (21), (33); |
| 11 |
BEGIN; |
| 12 |
DELETE FROM t1 WHERE a = 11; |
| 13 |
SELECT * FROM t1; |
| 14 |
a |
| 15 |
1 |
| 16 |
21 |
| 17 |
33 |
| 18 |
connect con1, localhost, root,,; |
| 19 |
ALTER TABLE t1 TRUNCATE PARTITION pMax; |
| 20 |
connection default; |
| 21 |
SELECT * FROM t1; |
| 22 |
a |
| 23 |
1 |
| 24 |
21 |
| 25 |
33 |
| 26 |
# Commit will allow the TRUNCATE to finish |
| 27 |
COMMIT; |
| 28 |
connection con1; |
| 29 |
disconnect con1; |
| 30 |
connection default; |
| 31 |
SELECT * FROM t1; |
| 32 |
a |
| 33 |
1 |
| 34 |
DROP TABLE t1; |
| 35 |
# |
| 36 |
# Bug#50561: ALTER PARTITIONS does not have adequate lock, breaks with |
| 37 |
# concurrent I_S query |
| 38 |
create table t1 (a int) |
| 39 |
engine = innodb stats_persistent=0 |
| 40 |
partition by range (a) |
| 41 |
(partition p0 values less than MAXVALUE); |
| 42 |
insert into t1 values (1), (11), (21), (33); |
| 43 |
SELECT * FROM t1; |
| 44 |
a |
| 45 |
1 |
| 46 |
11 |
| 47 |
21 |
| 48 |
33 |
| 49 |
SHOW CREATE TABLE t1; |
| 50 |
Table Create Table |
| 51 |
t1 CREATE TABLE `t1` ( |
| 52 |
`a` int(11) DEFAULT NULL |
| 53 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci STATS_PERSISTENT=0 |
| 54 |
PARTITION BY RANGE (`a`) |
| 55 |
(PARTITION `p0` VALUES LESS THAN MAXVALUE ENGINE = InnoDB) |
| 56 |
db.opt |
| 57 |
t1#P#p0.ibd |
| 58 |
t1.frm |
| 59 |
t1.par |
| 60 |
SET DEBUG_SYNC='before_open_in_get_all_tables SIGNAL parked WAIT_FOR open'; |
| 61 |
SET DEBUG_SYNC='partition_open_error SIGNAL alter WAIT_FOR finish'; |
| 62 |
SELECT TABLE_SCHEMA, TABLE_NAME, PARTITION_NAME, PARTITION_ORDINAL_POSITION, |
| 63 |
PARTITION_DESCRIPTION, TABLE_ROWS |
| 64 |
FROM INFORMATION_SCHEMA.PARTITIONS |
| 65 |
WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test'; |
| 66 |
connect con1, localhost, root,,; |
| 67 |
SET DEBUG_SYNC = 'now WAIT_FOR parked'; |
| 68 |
# When waiting for the name lock in get_all_tables in sql_show.cc |
| 69 |
# this will not be concurrent any more, thus the TIMEOUT |
| 70 |
SET DEBUG_SYNC = 'before_rename_partitions SIGNAL open WAIT_FOR alter TIMEOUT 1'; |
| 71 |
# Needs to be executed twice, since first is this 'SET DEBUG_SYNC ...' |
| 72 |
SET DEBUG_SYNC = 'before_close_thread_tables SIGNAL finish EXECUTE 2'; |
| 73 |
ALTER TABLE t1 REORGANIZE PARTITION p0 INTO |
| 74 |
(PARTITION p0 VALUES LESS THAN (10), |
| 75 |
PARTITION p10 VALUES LESS THAN MAXVALUE); |
| 76 |
Warnings: |
| 77 |
Warning 1639 debug sync point wait timed out |
| 78 |
disconnect con1; |
| 79 |
connection default; |
| 80 |
TABLE_SCHEMA TABLE_NAME PARTITION_NAME PARTITION_ORDINAL_POSITION PARTITION_DESCRIPTION TABLE_ROWS |
| 81 |
test t1 p0 1 10 1 |
| 82 |
test t1 p10 2 MAXVALUE 3 |
| 83 |
db.opt |
| 84 |
t1#P#p0.ibd |
| 85 |
t1#P#p10.ibd |
| 86 |
t1.frm |
| 87 |
t1.par |
| 88 |
SHOW CREATE TABLE t1; |
| 89 |
Table Create Table |
| 90 |
t1 CREATE TABLE `t1` ( |
| 91 |
`a` int(11) DEFAULT NULL |
| 92 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci STATS_PERSISTENT=0 |
| 93 |
PARTITION BY RANGE (`a`) |
| 94 |
(PARTITION `p0` VALUES LESS THAN (10) ENGINE = InnoDB, |
| 95 |
PARTITION `p10` VALUES LESS THAN MAXVALUE ENGINE = InnoDB) |
| 96 |
SELECT * FROM t1; |
| 97 |
a |
| 98 |
1 |
| 99 |
11 |
| 100 |
21 |
| 101 |
33 |
| 102 |
drop table t1; |
| 103 |
db.opt |
| 104 |
SET DEBUG_SYNC = 'RESET'; |