Skip to content

Commit

Permalink
MDEV-17923 Assertion failed in trx_undo_page_report_modify after CREA…
Browse files Browse the repository at this point in the history
…TE FULLTEXT INDEX

row_fts_merge_insert(): Correctly initialize DB_ROLL_PTR to a safe value
that will not be dereferenced by MVCC.
  • Loading branch information
dr-m committed Dec 7, 2018
1 parent 5ec9b88 commit 49a50a1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 11 deletions.
16 changes: 16 additions & 0 deletions mysql-test/suite/innodb_fts/r/create.result
Expand Up @@ -166,3 +166,19 @@ SELECT len,COUNT(*) FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS where name='word'
len COUNT(*)
84 6
DROP TABLE t;
#
# MDEV-17923 Assertion memcmp(field, field_ref_zero, 7) failed in
# trx_undo_page_report_modify upon optimizing table
# under innodb_optimize_fulltext_only
#
CREATE TABLE t1 (f1 TEXT, f2 TEXT, FULLTEXT KEY (f2)) ENGINE=InnoDB;
INSERT INTO t1 (f1) VALUES ('foo'),('bar');
DELETE FROM t1 LIMIT 1;
ALTER TABLE t1 ADD FULLTEXT KEY (f1);
SET @optimize_fulltext.save= @@innodb_optimize_fulltext_only;
SET GLOBAL innodb_optimize_fulltext_only= 1;
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
DROP TABLE t1;
SET GLOBAL innodb_optimize_fulltext_only= @optimize_fulltext.save;
16 changes: 16 additions & 0 deletions mysql-test/suite/innodb_fts/t/create.test
Expand Up @@ -90,3 +90,19 @@ ENGINE=InnoDB;
# The column length should be 84 bytes (84 characters * 1 byte/character).
SELECT len,COUNT(*) FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS where name='word' GROUP BY len;
DROP TABLE t;

--echo #
--echo # MDEV-17923 Assertion memcmp(field, field_ref_zero, 7) failed in
--echo # trx_undo_page_report_modify upon optimizing table
--echo # under innodb_optimize_fulltext_only
--echo #

CREATE TABLE t1 (f1 TEXT, f2 TEXT, FULLTEXT KEY (f2)) ENGINE=InnoDB;
INSERT INTO t1 (f1) VALUES ('foo'),('bar');
DELETE FROM t1 LIMIT 1;
ALTER TABLE t1 ADD FULLTEXT KEY (f1);
SET @optimize_fulltext.save= @@innodb_optimize_fulltext_only;
SET GLOBAL innodb_optimize_fulltext_only= 1;
OPTIMIZE TABLE t1;
DROP TABLE t1;
SET GLOBAL innodb_optimize_fulltext_only= @optimize_fulltext.save;
20 changes: 9 additions & 11 deletions storage/innobase/row/row0ftsort.cc
Expand Up @@ -1581,9 +1581,7 @@ row_fts_merge_insert(
dict_table_t* aux_table;
dict_index_t* aux_index;
trx_t* trx;
byte trx_id_buf[6];
roll_ptr_t roll_ptr = 0;
dfield_t* field;
byte sys_buf[DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN];

ut_ad(index);
ut_ad(table);
Expand Down Expand Up @@ -1689,16 +1687,16 @@ row_fts_merge_insert(
dict_index_get_n_fields(aux_index));

/* Set TRX_ID and ROLL_PTR */
trx_write_trx_id(trx_id_buf, trx->id);
field = dtuple_get_nth_field(ins_ctx.tuple, 2);
dfield_set_data(field, &trx_id_buf, 6);
trx_write_trx_id(sys_buf, trx->id);
trx_write_roll_ptr(sys_buf + DATA_TRX_ID_LEN,
1ULL << ROLL_PTR_INSERT_FLAG_POS);
dfield_set_data(dtuple_get_nth_field(ins_ctx.tuple, 2),
&sys_buf, DATA_TRX_ID_LEN);
dfield_set_data(dtuple_get_nth_field(ins_ctx.tuple, 3),
&sys_buf + DATA_TRX_ID_LEN, DATA_ROLL_PTR_LEN);

field = dtuple_get_nth_field(ins_ctx.tuple, 3);
dfield_set_data(field, &roll_ptr, 7);
ut_d(ins_ctx.aux_index_id = id);

#ifdef UNIV_DEBUG
ins_ctx.aux_index_id = id;
#endif
const ulint space = table->space;

for (i = 0; i < fts_sort_pll_degree; i++) {
Expand Down

0 comments on commit 49a50a1

Please sign in to comment.