diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-09-13 15:46:40 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-09-13 15:46:40 +0300 |
commit | 68ce0231ad6a16e02db9d67a217a88055b6d01ff (patch) | |
tree | 6f95ed40116dc8a2bd9802da344af91e12010130 | |
parent | 4c142433733fc6d0c360fd1a73b785bc2ebf89a9 (diff) | |
download | mariadb-git-68ce0231ad6a16e02db9d67a217a88055b6d01ff.tar.gz |
MDEV-23801 Assertion failed in btr_pcur_store_position()
btr_lift_page_up(): If the leaf page only contains a hidden metadata
record for MDEV-11369 instant ADD COLUMN, convert the table to the
canonical format like we are supposed to do whenever the table
becomes empty.
-rw-r--r-- | mysql-test/suite/innodb/r/instant_alter_bugs.result | 32 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/instant_alter_bugs.test | 41 | ||||
-rw-r--r-- | storage/innobase/btr/btr0btr.cc | 16 |
3 files changed, 87 insertions, 2 deletions
diff --git a/mysql-test/suite/innodb/r/instant_alter_bugs.result b/mysql-test/suite/innodb/r/instant_alter_bugs.result index b75566a4536..e34d6fcec35 100644 --- a/mysql-test/suite/innodb/r/instant_alter_bugs.result +++ b/mysql-test/suite/innodb/r/instant_alter_bugs.result @@ -201,4 +201,36 @@ SELECT * FROM t1; c1 c2 c3 1 0 10 DROP TABLE t1; +# +# MDEV-23801 Assertion index->table->instant... failed +# in btr_pcur_store_position() +# +SET @save_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency; +SET GLOBAL innodb_purge_rseg_truncate_frequency = 1; +CREATE TABLE t ( +pk int auto_increment, +c01 char(255) not null default repeat('a',255), +c02 char(255) default repeat('a',255), +c03 char(255) default repeat('a',255), +c04 char(255) default repeat('a',255), +c05 char(255) not null default repeat('a',255), +c06 char(255) default repeat('a',255), +c07 char(255) default repeat('a',255), +c08 char(255) not null default repeat('a',255), +c09 char(255) default repeat('a',255), +c10 char(255) default repeat('a',255), +c11 char(255) default repeat('a',255), +c12 char(255) not null default repeat('a',255), +primary key (pk) +) ENGINE=InnoDB CHARACTER SET ucs2; +INSERT INTO t () VALUES (); +ALTER TABLE t ADD c INT; +BEGIN; +INSERT INTO t () VALUES (),(); +ROLLBACK; +DELETE FROM t; +InnoDB 0 transactions not purged +SET GLOBAL innodb_purge_rseg_truncate_frequency = @save_frequency; +CREATE TABLE tt ENGINE=InnoDB AS SELECT c FROM t; +DROP TABLE t, tt; # End of 10.3 tests diff --git a/mysql-test/suite/innodb/t/instant_alter_bugs.test b/mysql-test/suite/innodb/t/instant_alter_bugs.test index a7ccefb19af..47689a6006c 100644 --- a/mysql-test/suite/innodb/t/instant_alter_bugs.test +++ b/mysql-test/suite/innodb/t/instant_alter_bugs.test @@ -204,4 +204,45 @@ ALTER TABLE t1 IMPORT TABLESPACE; SHOW CREATE TABLE t1; SELECT * FROM t1; DROP TABLE t1; + + +--echo # +--echo # MDEV-23801 Assertion index->table->instant... failed +--echo # in btr_pcur_store_position() +--echo # + +SET @save_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency; +SET GLOBAL innodb_purge_rseg_truncate_frequency = 1; + +CREATE TABLE t ( + pk int auto_increment, + c01 char(255) not null default repeat('a',255), + c02 char(255) default repeat('a',255), + c03 char(255) default repeat('a',255), + c04 char(255) default repeat('a',255), + c05 char(255) not null default repeat('a',255), + c06 char(255) default repeat('a',255), + c07 char(255) default repeat('a',255), + c08 char(255) not null default repeat('a',255), + c09 char(255) default repeat('a',255), + c10 char(255) default repeat('a',255), + c11 char(255) default repeat('a',255), + c12 char(255) not null default repeat('a',255), + primary key (pk) +) ENGINE=InnoDB CHARACTER SET ucs2; + +INSERT INTO t () VALUES (); +ALTER TABLE t ADD c INT; + +BEGIN; +INSERT INTO t () VALUES (),(); +ROLLBACK; +DELETE FROM t; + +--source include/wait_all_purged.inc +SET GLOBAL innodb_purge_rseg_truncate_frequency = @save_frequency; + +CREATE TABLE tt ENGINE=InnoDB AS SELECT c FROM t; +DROP TABLE t, tt; + --echo # End of 10.3 tests diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 2ef5495a510..2bba68f0f37 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -3331,6 +3331,7 @@ btr_lift_page_up( ut_ad(!page_has_siblings(page)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); + ut_ad(!page_is_empty(page)); page_level = btr_page_get_level(page); root_page_no = dict_index_get_page(index); @@ -3419,6 +3420,16 @@ btr_lift_page_up( if (index->is_instant() && father_block->page.id.page_no() == root_page_no) { ut_ad(!father_page_zip); + if (page_is_leaf(page)) { + ut_d(const rec_t* rec + = page_rec_get_next(page_get_infimum_rec(page))); + ut_ad(rec_is_metadata(rec, index)); + if (page_get_n_recs(page) == 1) { + index->remove_instant(); + goto copied; + } + } + byte* page_type = father_block->frame + FIL_PAGE_TYPE; ut_ad(mach_read_from_2(page_type) == FIL_PAGE_INDEX); mlog_write_ulint(page_type, FIL_PAGE_TYPE_INSTANT, @@ -3427,8 +3438,6 @@ btr_lift_page_up( index->n_core_fields, mtr); } - page_level++; - /* Copy the records to the father page one by one. */ if (0 #ifdef UNIV_ZIP_COPY @@ -3460,6 +3469,7 @@ btr_lift_page_up( } } +copied: if (!dict_table_is_locking_disabled(index->table)) { /* Free predicate page locks on the block */ if (dict_index_is_spatial(index)) { @@ -3471,6 +3481,8 @@ btr_lift_page_up( lock_update_copy_and_discard(father_block, block); } + page_level++; + /* Go upward to root page, decrementing levels by one. */ for (i = lift_father_up ? 1 : 0; i < n_blocks; i++, page_level++) { page_t* page = buf_block_get_frame(blocks[i]); |