[MDEV-17459] Allow instant ALTER TABLE even if FULLTEXT INDEX exists Created: 2018-10-15  Updated: 2023-07-27

Status: Stalled
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.3, 10.4
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Thirunarayanan Balathandayuthapani
Resolution: Unresolved Votes: 0
Labels: fulltext, instant

Issue Links:
Relates
relates to MDEV-18623 Assertion `ha_alter_info->key_count +... Closed
relates to MDEV-20237 Block instant alter operation for the... Stalled
relates to MDEV-11369 Instant add column for InnoDB Closed
relates to MDEV-11424 Instant ALTER TABLE of failure-free r... Closed
relates to MDEV-15562 Instant DROP COLUMN or changing the o... Closed

 Description   

The function fts_fetch_doc_from_rec() and possibly other code for dealing with FULLTEXT INDEX assumes that no instant ALTER TABLE has been used.

It seems that this code may not be ready for MDEV-11369 either.

The following raw test demonstrates the problem:

--source include/have_innodb.inc
--disable_abort_on_error
--disable_warnings
 
CREATE TABLE IF NOT EXISTS t1 (col1 INT, col2 INT, col_int INTEGER, col_text TEXT) ENGINE = InnoDB  ;
ALTER TABLE t1 ADD FULLTEXT KEY `Marvão_ftidx1` ( col_text ), ADD FULLTEXT KEY IF NOT EXISTS `Marvão_ftidx1` ( col_text )  ;
INSERT INTO t1 (col1,col2, col_int, col_text) VALUES ( 1, 1, 1 - 1, REPEAT(CAST( 1 AS CHAR(1)), @fill_amount) ) ;
ALTER TABLE t1 ADD COLUMN col_int_copy INTEGER FIRST, ALGORITHM = DEFAULT  ;
ALTER TABLE t1 DROP COLUMN IF EXISTS col_int  ;
ALTER TABLE t1 CHANGE COLUMN IF EXISTS col_int_copy Col_int INTEGER, LOCK = NONE, ALGORITHM = INPLACE  ;
UPDATE t1 SET col1 = 28 LIMIT 2;
ALTER TABLE t1 ADD FULLTEXT KEY `Marvão_ftidx1` ( col_text ), ADD FULLTEXT KEY IF NOT EXISTS `Marvão_ftidx1` ( col_text )  ;
INSERT INTO t1 (col1,col2, col_int, col_text) VALUES ( 1, 1, 1 - 1, REPEAT(CAST( 1 AS CHAR(1)), @fill_amount) ) ;
DROP TABLE t1;

10.4-mdev-15562 ba5168fd8fa96a580645ecb0450e8ac5d53c86dd

mysqld: fts/fts0fts.cc:3265: void fts_fetch_doc_from_rec(fts_get_doc_t*, dict_index_t*, btr_pcur_t*, ulint*, fts_doc_t*): Assertion `!page_rec_is_comp(clust_rec) || rec_get_status(clust_rec) == REC_STATUS_ORDINARY' failed.

I believe that a similar failure should be possible already on 10.3 when a user-created FTS_DOC_ID exists and MDEV-11369 Instant ADD COLUMN is used. Please clean up the test and check if 10.3 is affected.

Suggestions:

  1. Ensure that the hidden metadata record is always skipped. (Add debug assertions.)
  2. Properly handle records on which instantly added fields are present.
  3. Also test with UNIQUE INDEX FTS_DOC_ID_INDEX(FTS_DOC_ID) such that the table does not have any PRIMARY KEY.


 Comments   
Comment by Marko Mäkelä [ 2019-04-01 ]

In MariaDB 10.4.4, MDEV-18623 will add more work to this bug: the instantaneous removal of NOT NULL attribute for ROW_FORMAT=REDUNDANT tables will be rejected if the FTS_DOC_ID column would be dropped. We should allow the column to be dropped instantaneously, instead of causing the table to be rebuilt.

Generated at Thu Feb 08 08:36:37 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.