Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-40804

Interrupted CREATE TABLE with a FULLTEXT index leaves use_stopword empty and stopwords off

    XMLWordPrintable

Details

    Description

      --source include/have_innodb.inc
      # An interrupted CREATE TABLE with a FULLTEXT index must keep the table stopword setting.
      # The stopword 'the' must not be indexed, so each count is 0.
      SET SESSION max_statement_time=0.001;
      CREATE TABLE ct1 (id INT PRIMARY KEY, txt TEXT, FULLTEXT(txt)) ENGINE=InnoDB;
      SET SESSION max_statement_time=0.005;
      CREATE TABLE ct2 (id INT PRIMARY KEY, txt TEXT, FULLTEXT(txt)) ENGINE=InnoDB;
      SET SESSION max_statement_time=0.02;
      CREATE TABLE ct3 (id INT PRIMARY KEY, txt TEXT, FULLTEXT(txt)) ENGINE=InnoDB;
      SET SESSION max_statement_time=0;
      INSERT INTO ct1 VALUES (1,'the quick brown fox');
      INSERT INTO ct2 VALUES (1,'the quick brown fox');
      INSERT INTO ct3 VALUES (1,'the quick brown fox');
      SELECT COUNT(*) FROM ct1 WHERE MATCH(txt) AGAINST('the');
      SELECT COUNT(*) FROM ct2 WHERE MATCH(txt) AGAINST('the');
      SELECT COUNT(*) FROM ct3 WHERE MATCH(txt) AGAINST('the');
      DROP TABLE ct1,ct2,ct3;
      

      Leads to:

      CS 13.1.0 0ee34e07bdc10abf32a535d7234c6f5e0bb9ed55 (Debug, Clang 22.1.8-20260622) Build 14/08/2026

      2026-08-18  8:48:56 4 [ERROR] InnoDB: (Operation interrupted) writing `use_stopword'
      

      The effect, comparing an interrupted table against a clean one. the is a default stopword, so it must not be indexed:

      USE test;
      SET SESSION max_statement_time=0.001;
      CREATE TABLE ct1 (id INT PRIMARY KEY, txt TEXT, FULLTEXT(txt)) ENGINE=InnoDB;
      SET SESSION max_statement_time=0;
      CREATE TABLE ct2 (id INT PRIMARY KEY, txt TEXT, FULLTEXT(txt)) ENGINE=InnoDB;
      INSERT INTO ct1 VALUES (1,'the quick brown fox');
      INSERT INTO ct2 VALUES (1,'the quick brown fox');
      SELECT COUNT(*) AS ct1_the FROM ct1 WHERE MATCH(txt) AGAINST('the');
      SELECT COUNT(*) AS ct2_the FROM ct2 WHERE MATCH(txt) AGAINST('the');
      SELECT COUNT(*) AS ct1_fox FROM ct1 WHERE MATCH(txt) AGAINST('fox');
      SELECT COUNT(*) AS ct2_fox FROM ct2 WHERE MATCH(txt) AGAINST('fox');
      SET GLOBAL innodb_ft_aux_table='test/ct1';
      SELECT * FROM information_schema.INNODB_FT_CONFIG;
      SET GLOBAL innodb_ft_aux_table='test/ct2';
      SELECT * FROM information_schema.INNODB_FT_CONFIG;
      

      ct1_the
      1
      ct2_the
      0
      ct1_fox
      1
      ct2_fox
      1
      KEY	VALUE
      optimize_checkpoint_limit	180
      synced_doc_id	0
      stopword_table_name	
      use_stopword	
      KEY	VALUE
      optimize_checkpoint_limit	180
      synced_doc_id	0
      stopword_table_name	
      use_stopword	1
      

      ct1 indexed the stopword, ct2 did not. Both match fox, so the index otherwise works. use_stopword is empty for ct1 and 1 for ct2.

      The write path, and where the interrupt enters it:

      create_table_info_t::create_table_update_dict()      ha_innodb.cc:13499
        innobase_fts_load_stopword()                       ha_innodb.cc:11724
          innobase_fts_update_stopword_config()            ha_innodb.cc:11653
            fts_config_set_ulint()                         fts0config.cc:171   <- logs the error
              fts_config_set_value()                       fts0config.cc:125
                FTSQueryExecutor::update_config_record()   fts0exec.cc:351
                  QueryExecutor::replace_record()          row0query.cc:495
                    QueryExecutor::select_for_update()
                      row_search_mvcc()                    row0sel.cc:5022     <- returns DB_INTERRUPTED
      

      innobase_fts_update_stopword_config() returns false on that error, so innobase_fts_load_stopword() fails and fts_optimize_add_table() is skipped. The CREATE TABLE itself still commits and reports success.

      Nothing later repairs it. The reader in fts0fts.cc:5052 takes the empty value through strtoul(), which gives 0, sets cache->stopword_info.status to STOPWORD_OFF and returns success. So an empty value reads as "stopwords are off" and raises no error. The value is on disk, so a restart does not clear it: after a restart MATCH(txt) AGAINST('the') still returns the row and use_stopword is still empty.

      trx_is_interrupted() in ha_innodb.cc:3621 is true for any statement whose kill level is set, so KILL QUERY and a lost client connection reach the same path. max_statement_time is only the easiest way to show it.

      On 13.0 this config value is written through the InnoDB internal parser, fts_parse_sql() plus fts_eval_sql(), which runs the statement in the que layer. That layer holds no interrupt check, so the write finishes even after the statement timer has expired. MDEV-28730, commit 81c3836bb2ba0823fe69fd6953c21fccf6476b92, replaced the internal parser with FTSQueryExecutor, and the new path runs through row_search_mvcc(), which does check. The same CREATE TABLE takes 26.8 ms on CS 13.0.2 and 29.5 ms on CS 13.1.0, so a 1 ms timer expires on both, yet only CS 13.1.0 loses the value.

      Bug Detection Matrix

          Rel    o/d  Build   Commit                                    UniqueID observed             
      CS  10.6   dbg  220726  5520c9aac5b6a5a9ea60d78582ddffa5349e2d0f  No bug found                  
      CS  10.6   opt  220726  5520c9aac5b6a5a9ea60d78582ddffa5349e2d0f  No bug found                  
      CS  10.11  dbg  220726  6268f6023fe3e8dc8ec81869dea711e14cbb28c3  No bug found                  
      CS  10.11  opt  220726  6268f6023fe3e8dc8ec81869dea711e14cbb28c3  No bug found                  
      CS  11.4   dbg  220726  2cbce592c39dd39902c8f03db2b35069832fd10b  No bug found                  
      CS  11.4   opt  220726  2cbce592c39dd39902c8f03db2b35069832fd10b  No bug found                  
      CS  11.8   dbg  220726  1d23deff797ab448f091e39756434903d81a98c2  No bug found                  
      CS  11.8   opt  220726  1d23deff797ab448f091e39756434903d81a98c2  No bug found                  
      CS  12.3   dbg  220726  9b075b2cb53338f67e7230cc585e02d2d34514ed  No bug found                  
      CS  12.3   opt  220726  9b075b2cb53338f67e7230cc585e02d2d34514ed  No bug found                  
      CS  13.0   dbg  220726  84c246ca5387c0611f75097136ff4f4bea092aa3  No bug found                  
      CS  13.0   opt  220726  84c246ca5387c0611f75097136ff4f4bea092aa3  No bug found                  
      CS  13.1   dbg  140826  0ee34e07bdc10abf32a535d7234c6f5e0bb9ed55  INNODB_ERROR|(Operation interrupted) writing `use_stopword'
      CS  13.1   opt  140826  0ee34e07bdc10abf32a535d7234c6f5e0bb9ed55  INNODB_ERROR|(Operation interrupted) writing `use_stopword'
      ES  10.6   dbg  220726  fcecb2620f25965723d640decede7c018bcb1dcc  No bug found                  
      ES  10.6   opt  220726  fcecb2620f25965723d640decede7c018bcb1dcc  No bug found                  
      ES  11.4   dbg  220726  3b34189bfe675c18c4ced3ef531d016ea74c76f4  No bug found                  
      ES  11.4   opt  220726  3b34189bfe675c18c4ced3ef531d016ea74c76f4  No bug found                  
      ES  11.8   dbg  220726  4694e931d10fecf733c34f83ea2146d31b708eb3  No bug found                  
      ES  11.8   opt  220726  4694e931d10fecf733c34f83ea2146d31b708eb3  No bug found                  
      ES  12.3   dbg  220726  9d8abb61e913bec023cd8caeccad4b42717151cb  No bug found                  
      ES  12.3   opt  220726  9d8abb61e913bec023cd8caeccad4b42717151cb  No bug found                  
      

      Attachments

        Issue Links

          Activity

            People

              thiru Thirunarayanan Balathandayuthapani
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 3h 35m
                  3h 35m

                  Git Integration

                    Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.