Skip to content

Commit 0bdd6cb

Browse files
authored
mariadb 11.8 wrapper: fix hlindex assertion failure in wrapper mode with FULLTEXT indexes (mroonga#977)
GitHub: mroongaGH-943 ## Issue The test `mroonga/wrapper/alter_table.change_engine` was failing with an assertion error during ALTER TABLE operations that change MyISAM tables with FULLTEXT indexes to Mroonga wrapper mode: ``` - saving '/home/otegami/work/cpp/mariadb-11.8.3.build/mysql-test/var/3/log/mroonga/wrapper/alter_table.change_engine/' to '/home/otegami/work/cpp/mariadb-11.8.3.build/mysql-test/var/log/alter_table.change_engine/' ***Warnings generated in error logs during shutdown after running tests: mroonga/wrapper/alter_table.change_engine mariadbd: /home/otegami/work/cpp/mariadb-11.8.3/sql/sql_base.cc:10018: int TABLE::hlindexes_on_insert(): Assertion `s->hlindexes() == (hlindex != __null)' failed. 250910 10:31:10 [ERROR] /home/otegami/work/cpp/mariadb-11.8.3.build/sql/mariadbd got signal 6 ; Attempting backtrace. Include this in the bug report. ``` The crash occurred during `copy_data_between_tables()` when the wrapped handler (InnoDB) attempted to insert rows, specifically when `TABLE::hlindexes_on_insert()` was called. ## Cause When Mroonga operates in wrapper mode, it creates a `wrap_table_share` structure that excludes FULLTEXT and SPATIAL indexes since these are handled by Mroonga rather than the wrapped storage engine. The bug occurred because: 1. The `wrap_table_share` was created by copying all fields from the original table share 2. The `keys` field was correctly updated to reflect only wrapper-handled keys (non-FULLTEXT, non-SPATIAL) 3. However, `total_keys` was not updated and remained at the original value 4. This caused `hlindexes()` (calculated as `total_keys - keys`) to return a non-zero value, incorrectly indicating that the wrapper handler should handle FULLTEXT indexes 5. Since `hlindex` was NULL but `hlindexes() > 0`, the assertion `s->hlindexes() == (hlindex != NULL)` failed For example, with a table having 2 FULLTEXT indexes: - Actual: Original table share: `hlindexes()=2` - Expected: table share: `hlindexes()=0` ## Solution Fixed by setting `wrap_table_share->total_keys = share->wrap_keys` in `mrn_table.cpp`. This ensures that for the wrapper table share, `total_keys` equals `keys`, making `hlindexes()` return 0, which correctly indicates that the wrapper handler doesn't handle FULLTEXT indexes. Related MariaDB commit: MariaDB/server@d6add9a It also uses this solution.
1 parent 6c474c1 commit 0bdd6cb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mrn_table.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,9 @@ MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error)
864864
wrap_table_share->keys = share->wrap_keys;
865865
wrap_table_share->key_info = share->wrap_key_info;
866866
wrap_table_share->primary_key = share->wrap_primary_key;
867+
#if defined(MRN_MARIADB_P) && (MYSQL_VERSION_ID >= 110800)
868+
wrap_table_share->total_keys = share->wrap_keys;
869+
#endif
867870
wrap_table_share->keys_in_use.init(share->wrap_keys);
868871
wrap_table_share->keys_for_keyread.init(share->wrap_keys);
869872
# ifdef MRN_TABLE_SHARE_HAVE_LOCK_SHARE

0 commit comments

Comments
 (0)