Skip to content

Commit 3171d5c

Browse files
committed
Bug#33924532 : Assert failure in purge which tries to purge UNDO across INSTANT DDL
RB : 27740 Reviewed by : Debarun Banerjee <[email protected]>
1 parent 4cebfd3 commit 3171d5c

File tree

11 files changed

+301
-13
lines changed

11 files changed

+301
-13
lines changed

mysql-test/suite/innodb/include/instant_ddl_misc.inc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,24 @@ ALTER TABLE t1 TRUNCATE partition p0, p1, p2, p3;
922922

923923
DROP TABLE t1;
924924

925+
--echo # Scenario 66
926+
--echo # Purge crash
927+
--eval create table t1 (c0 INT KEY, c1 varchar(10), c2 varchar(10)) ROW_FORMAT=$row_format
928+
929+
alter table t1 add column c4 char(10), algorithm=instant;
930+
alter table t1 add index idx (c4);
931+
932+
insert into t1 values (1, "r1c1", "r1c2", "c4");
933+
SET GLOBAL innodb_purge_stop_now=ON;
934+
Update t1 set c2="r122222", c4="c44";
935+
936+
alter table t1 drop column c2, algorithm=instant;
937+
938+
SET GLOBAL innodb_purge_run_now=ON;
939+
--source include/wait_innodb_all_purged.inc
940+
941+
DROP TABLE t1;
942+
925943
--echo ###########
926944
--echo # CLEANUP #
927945
--echo ###########

mysql-test/suite/innodb/include/instant_ddl_update.inc

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ if ($is_debug)
149149
--echo # ---------------------------
150150
--source include/count_sessions.inc
151151

152-
--eval CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=$row_format;
152+
--eval CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=$row_format
153153
INSERT INTO t1 VALUES ("r1c1", "r1c2");
154154
SELECT * FROM t1;
155155

@@ -201,7 +201,7 @@ if ($is_debug)
201201
--echo # ---------------------------
202202
--source include/count_sessions.inc
203203

204-
--eval CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=$row_format;
204+
--eval CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=$row_format
205205
INSERT INTO t1 VALUES ("r1c1", "r1c2");
206206
SELECT * FROM t1;
207207

@@ -244,6 +244,55 @@ if ($is_debug)
244244

245245
DISCONNECT con1;
246246

247+
# Wait till all disconnects are completed
248+
--source include/wait_until_count_sessions.inc
249+
DROP TABLE t1;
250+
251+
--echo # -----------------------
252+
--echo # ONLINE DDL 3 :
253+
--echo # -----------------------
254+
--eval create table t1 (c1 char(10), c2 char(10)) ROW_FORMAT=$row_format
255+
Insert into t1 values ("r1c1", "r1c2");
256+
Select * from t1;
257+
258+
alter table t1 add column c3 char(10) default "c3_def", algorithm=instant;
259+
Select * from t1;
260+
261+
Insert into t1 values ("r2c1", "r2c2", "r2c3");
262+
Select * from t1;
263+
264+
Alter table t1 add column c4 char(10) default "c4_def" first, algorithm=INSTANT;
265+
Select * from t1;
266+
267+
Insert into t1 values ("r3c4", "r3c1", "r3c2", "r3c3");
268+
Select * from t1;
269+
270+
--echo # Make alter table wait
271+
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL s1 WAIT_FOR s2';
272+
273+
--echo # Rebuild the table
274+
--send_eval ALTER TABLE t1 force, algorithm=inplace;
275+
276+
connect (con1,localhost,root,,);
277+
--echo # connection con1
278+
connection con1;
279+
280+
SET DEBUG_SYNC = 'now WAIT_FOR s1';
281+
282+
--echo # Update query
283+
eval UPDATE t1 SET c1="c1_upd";
284+
285+
--echo # Let Alter table continue
286+
SET DEBUG_SYNC = 'now SIGNAL s2';
287+
288+
--echo # connection default
289+
connection default;
290+
--reap
291+
292+
SELECT * FROM t1;
293+
294+
DISCONNECT con1;
295+
247296
# Wait till all disconnects are completed
248297
--source include/wait_until_count_sessions.inc
249298
}

mysql-test/suite/innodb/r/instant_ddl_misc.result

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,17 @@ c2 1 6 1027 0 0 0
17881788
c4 2 5 16711932 0 0 0
17891789
c5 3 6 1027 0 0 0
17901790
DROP TABLE t1;
1791+
# Scenario 66
1792+
# Purge crash
1793+
create table t1 (c0 INT KEY, c1 varchar(10), c2 varchar(10)) ROW_FORMAT=REDUNDANT;
1794+
alter table t1 add column c4 char(10), algorithm=instant;
1795+
alter table t1 add index idx (c4);
1796+
insert into t1 values (1, "r1c1", "r1c2", "c4");
1797+
SET GLOBAL innodb_purge_stop_now=ON;
1798+
Update t1 set c2="r122222", c4="c44";
1799+
alter table t1 drop column c2, algorithm=instant;
1800+
SET GLOBAL innodb_purge_run_now=ON;
1801+
DROP TABLE t1;
17911802
###########
17921803
# CLEANUP #
17931804
###########
@@ -3581,6 +3592,17 @@ c2 1 6 1027 0 0 0
35813592
c4 2 5 16711932 0 0 0
35823593
c5 3 6 1027 0 0 0
35833594
DROP TABLE t1;
3595+
# Scenario 66
3596+
# Purge crash
3597+
create table t1 (c0 INT KEY, c1 varchar(10), c2 varchar(10)) ROW_FORMAT=DYNAMIC;
3598+
alter table t1 add column c4 char(10), algorithm=instant;
3599+
alter table t1 add index idx (c4);
3600+
insert into t1 values (1, "r1c1", "r1c2", "c4");
3601+
SET GLOBAL innodb_purge_stop_now=ON;
3602+
Update t1 set c2="r122222", c4="c44";
3603+
alter table t1 drop column c2, algorithm=instant;
3604+
SET GLOBAL innodb_purge_run_now=ON;
3605+
DROP TABLE t1;
35843606
###########
35853607
# CLEANUP #
35863608
###########
@@ -5374,6 +5396,17 @@ c2 1 6 1027 0 0 0
53745396
c4 2 5 16711932 0 0 0
53755397
c5 3 6 1027 0 0 0
53765398
DROP TABLE t1;
5399+
# Scenario 66
5400+
# Purge crash
5401+
create table t1 (c0 INT KEY, c1 varchar(10), c2 varchar(10)) ROW_FORMAT=COMPACT;
5402+
alter table t1 add column c4 char(10), algorithm=instant;
5403+
alter table t1 add index idx (c4);
5404+
insert into t1 values (1, "r1c1", "r1c2", "c4");
5405+
SET GLOBAL innodb_purge_stop_now=ON;
5406+
Update t1 set c2="r122222", c4="c44";
5407+
alter table t1 drop column c2, algorithm=instant;
5408+
SET GLOBAL innodb_purge_run_now=ON;
5409+
DROP TABLE t1;
53775410
###########
53785411
# CLEANUP #
53795412
###########

mysql-test/suite/innodb/r/instant_ddl_update_debug.result

Lines changed: 141 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ DROP TABLE t1;
411411
# ---------------------------
412412
# ONLINE DDL 1 : NO PK CHANGE
413413
# ---------------------------
414-
CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=REDUNDANT;;
414+
CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=REDUNDANT;
415415
INSERT INTO t1 VALUES ("r1c1", "r1c2");
416416
SELECT * FROM t1;
417417
c1 c2
@@ -453,7 +453,7 @@ DROP TABLE t1;
453453
# ---------------------------
454454
# ONLINE DDL 2 : PK CHANGE
455455
# ---------------------------
456-
CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=REDUNDANT;;
456+
CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=REDUNDANT;
457457
INSERT INTO t1 VALUES ("r1c1", "r1c2");
458458
SELECT * FROM t1;
459459
c1 c2
@@ -491,6 +491,51 @@ c0_upd r1c2
491491
c0_upd r2c2
492492
c0_upd r3c2
493493
c0_upd r4c2
494+
DROP TABLE t1;
495+
# -----------------------
496+
# ONLINE DDL 3 :
497+
# -----------------------
498+
create table t1 (c1 char(10), c2 char(10)) ROW_FORMAT=REDUNDANT;
499+
Insert into t1 values ("r1c1", "r1c2");
500+
Select * from t1;
501+
c1 c2
502+
r1c1 r1c2
503+
alter table t1 add column c3 char(10) default "c3_def", algorithm=instant;
504+
Select * from t1;
505+
c1 c2 c3
506+
r1c1 r1c2 c3_def
507+
Insert into t1 values ("r2c1", "r2c2", "r2c3");
508+
Select * from t1;
509+
c1 c2 c3
510+
r1c1 r1c2 c3_def
511+
r2c1 r2c2 r2c3
512+
Alter table t1 add column c4 char(10) default "c4_def" first, algorithm=INSTANT;
513+
Select * from t1;
514+
c4 c1 c2 c3
515+
c4_def r1c1 r1c2 c3_def
516+
c4_def r2c1 r2c2 r2c3
517+
Insert into t1 values ("r3c4", "r3c1", "r3c2", "r3c3");
518+
Select * from t1;
519+
c4 c1 c2 c3
520+
c4_def r1c1 r1c2 c3_def
521+
c4_def r2c1 r2c2 r2c3
522+
r3c4 r3c1 r3c2 r3c3
523+
# Make alter table wait
524+
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL s1 WAIT_FOR s2';
525+
# Rebuild the table
526+
ALTER TABLE t1 force, algorithm=inplace;;
527+
# connection con1
528+
SET DEBUG_SYNC = 'now WAIT_FOR s1';
529+
# Update query
530+
UPDATE t1 SET c1="c1_upd";
531+
# Let Alter table continue
532+
SET DEBUG_SYNC = 'now SIGNAL s2';
533+
# connection default
534+
SELECT * FROM t1;
535+
c4 c1 c2 c3
536+
c4_def c1_upd r1c2 c3_def
537+
c4_def c1_upd r2c2 r2c3
538+
r3c4 c1_upd r3c2 r3c3
494539
###########
495540
# CLEANUP #
496541
###########
@@ -908,7 +953,7 @@ DROP TABLE t1;
908953
# ---------------------------
909954
# ONLINE DDL 1 : NO PK CHANGE
910955
# ---------------------------
911-
CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=DYNAMIC;;
956+
CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=DYNAMIC;
912957
INSERT INTO t1 VALUES ("r1c1", "r1c2");
913958
SELECT * FROM t1;
914959
c1 c2
@@ -950,7 +995,7 @@ DROP TABLE t1;
950995
# ---------------------------
951996
# ONLINE DDL 2 : PK CHANGE
952997
# ---------------------------
953-
CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=DYNAMIC;;
998+
CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=DYNAMIC;
954999
INSERT INTO t1 VALUES ("r1c1", "r1c2");
9551000
SELECT * FROM t1;
9561001
c1 c2
@@ -988,6 +1033,51 @@ c0_upd r1c2
9881033
c0_upd r2c2
9891034
c0_upd r3c2
9901035
c0_upd r4c2
1036+
DROP TABLE t1;
1037+
# -----------------------
1038+
# ONLINE DDL 3 :
1039+
# -----------------------
1040+
create table t1 (c1 char(10), c2 char(10)) ROW_FORMAT=DYNAMIC;
1041+
Insert into t1 values ("r1c1", "r1c2");
1042+
Select * from t1;
1043+
c1 c2
1044+
r1c1 r1c2
1045+
alter table t1 add column c3 char(10) default "c3_def", algorithm=instant;
1046+
Select * from t1;
1047+
c1 c2 c3
1048+
r1c1 r1c2 c3_def
1049+
Insert into t1 values ("r2c1", "r2c2", "r2c3");
1050+
Select * from t1;
1051+
c1 c2 c3
1052+
r1c1 r1c2 c3_def
1053+
r2c1 r2c2 r2c3
1054+
Alter table t1 add column c4 char(10) default "c4_def" first, algorithm=INSTANT;
1055+
Select * from t1;
1056+
c4 c1 c2 c3
1057+
c4_def r1c1 r1c2 c3_def
1058+
c4_def r2c1 r2c2 r2c3
1059+
Insert into t1 values ("r3c4", "r3c1", "r3c2", "r3c3");
1060+
Select * from t1;
1061+
c4 c1 c2 c3
1062+
c4_def r1c1 r1c2 c3_def
1063+
c4_def r2c1 r2c2 r2c3
1064+
r3c4 r3c1 r3c2 r3c3
1065+
# Make alter table wait
1066+
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL s1 WAIT_FOR s2';
1067+
# Rebuild the table
1068+
ALTER TABLE t1 force, algorithm=inplace;;
1069+
# connection con1
1070+
SET DEBUG_SYNC = 'now WAIT_FOR s1';
1071+
# Update query
1072+
UPDATE t1 SET c1="c1_upd";
1073+
# Let Alter table continue
1074+
SET DEBUG_SYNC = 'now SIGNAL s2';
1075+
# connection default
1076+
SELECT * FROM t1;
1077+
c4 c1 c2 c3
1078+
c4_def c1_upd r1c2 c3_def
1079+
c4_def c1_upd r2c2 r2c3
1080+
r3c4 c1_upd r3c2 r3c3
9911081
###########
9921082
# CLEANUP #
9931083
###########
@@ -1405,7 +1495,7 @@ DROP TABLE t1;
14051495
# ---------------------------
14061496
# ONLINE DDL 1 : NO PK CHANGE
14071497
# ---------------------------
1408-
CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=COMPACT;;
1498+
CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=COMPACT;
14091499
INSERT INTO t1 VALUES ("r1c1", "r1c2");
14101500
SELECT * FROM t1;
14111501
c1 c2
@@ -1447,7 +1537,7 @@ DROP TABLE t1;
14471537
# ---------------------------
14481538
# ONLINE DDL 2 : PK CHANGE
14491539
# ---------------------------
1450-
CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=COMPACT;;
1540+
CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=COMPACT;
14511541
INSERT INTO t1 VALUES ("r1c1", "r1c2");
14521542
SELECT * FROM t1;
14531543
c1 c2
@@ -1485,6 +1575,51 @@ c0_upd r1c2
14851575
c0_upd r2c2
14861576
c0_upd r3c2
14871577
c0_upd r4c2
1578+
DROP TABLE t1;
1579+
# -----------------------
1580+
# ONLINE DDL 3 :
1581+
# -----------------------
1582+
create table t1 (c1 char(10), c2 char(10)) ROW_FORMAT=COMPACT;
1583+
Insert into t1 values ("r1c1", "r1c2");
1584+
Select * from t1;
1585+
c1 c2
1586+
r1c1 r1c2
1587+
alter table t1 add column c3 char(10) default "c3_def", algorithm=instant;
1588+
Select * from t1;
1589+
c1 c2 c3
1590+
r1c1 r1c2 c3_def
1591+
Insert into t1 values ("r2c1", "r2c2", "r2c3");
1592+
Select * from t1;
1593+
c1 c2 c3
1594+
r1c1 r1c2 c3_def
1595+
r2c1 r2c2 r2c3
1596+
Alter table t1 add column c4 char(10) default "c4_def" first, algorithm=INSTANT;
1597+
Select * from t1;
1598+
c4 c1 c2 c3
1599+
c4_def r1c1 r1c2 c3_def
1600+
c4_def r2c1 r2c2 r2c3
1601+
Insert into t1 values ("r3c4", "r3c1", "r3c2", "r3c3");
1602+
Select * from t1;
1603+
c4 c1 c2 c3
1604+
c4_def r1c1 r1c2 c3_def
1605+
c4_def r2c1 r2c2 r2c3
1606+
r3c4 r3c1 r3c2 r3c3
1607+
# Make alter table wait
1608+
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL s1 WAIT_FOR s2';
1609+
# Rebuild the table
1610+
ALTER TABLE t1 force, algorithm=inplace;;
1611+
# connection con1
1612+
SET DEBUG_SYNC = 'now WAIT_FOR s1';
1613+
# Update query
1614+
UPDATE t1 SET c1="c1_upd";
1615+
# Let Alter table continue
1616+
SET DEBUG_SYNC = 'now SIGNAL s2';
1617+
# connection default
1618+
SELECT * FROM t1;
1619+
c4 c1 c2 c3
1620+
c4_def c1_upd r1c2 c3_def
1621+
c4_def c1_upd r2c2 r2c3
1622+
r3c4 c1_upd r3c2 r3c3
14881623
###########
14891624
# CLEANUP #
14901625
###########

storage/innobase/data/data0data.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,8 @@ big_rec_t *dtuple_convert_big_rec(dict_index_t *index, upd_t *upd,
586586

587587
upd_field_t upd_field;
588588
upd_field.field_no = longest_i;
589+
IF_DEBUG(upd_field.field_phy_pos =
590+
index->get_field(longest_i)->col->get_col_phy_pos();)
589591
upd_field.orig_len = 0;
590592
upd_field.exp = nullptr;
591593
upd_field.old_v_val = nullptr;

storage/innobase/handler/ha_innodb.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9421,6 +9421,12 @@ static dberr_t calc_row_difference(
94219421
} else {
94229422
ufield->field_no = dict_col_get_clust_pos(
94239423
&prebuilt->table->cols[i - num_v], clust_index);
9424+
#ifdef UNIV_DEBUG
9425+
if (clust_index->has_row_versions()) {
9426+
dict_col_t *col = &prebuilt->table->cols[i - num_v];
9427+
ufield->field_phy_pos = col->get_col_phy_pos();
9428+
}
9429+
#endif
94249430
ufield->old_v_val = nullptr;
94259431
}
94269432
n_changed++;

storage/innobase/include/row0upd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ struct upd_field_t {
486486
this is the position in the secondary
487487
index, also it could be the position
488488
in virtual index for virtual column */
489+
IF_DEBUG(uint16_t field_phy_pos{UINT16_MAX};)
489490
unsigned orig_len : 16; /*!< original length of the locally
490491
stored part of an externally stored
491492
column, or 0 */

0 commit comments

Comments
 (0)