Commit accb4af
committed
MDEV-31892 Server crash upon moving InnoDB table with
fulltext index between databases
Problem:
========
- When renaming/moving an InnoDB table with fulltext indexes
between databases, the server would crash because
InnoDB attempted to open auxiliary tables using
the old database name instead of the new one.
When creating auxiliary index, InnoDB does create temporary
sort fulltext index using old table reference which creates
the auxiliary table name with the prefix of old database name.
FTS Document ID size optimization in row_merge_create_fts_sort_index()
using dict_table_get_n_rows() to decide between 4-byte
and 8-byte Doc IDs for memory optimization. But
dict_table_get_n_rows() returns estimated statistics that
may be stale or inaccurate, potentially leading to wrong
size decisions and data corruption if 4-byte
Doc IDs are chosen when 8-byte are actually needed.
Solution:
=========
fts_rename_aux_tables(): Iterate through all table indexes
and ensure all fulltext indexes are properly renamed
row_merge_create_fts_sort_index() : Use new_table instead
of old_table when creating temporary FTS sort indexes.
row_merge_build_indexes(): Refactored the logic to do
memory optimization to determine the doc id size for
temporary fts sort index.
- When adding FTS index for the first time
(DICT_TF2_FTS_ADD_DOC_ID), always use 8-byte Doc IDs
- For existing FTS tables or user-supplied Doc ID columns,
use fts_get_max_doc_id() approach to check actual maximum Doc ID1 parent 08ba31f commit accb4af
File tree
6 files changed
+54
-37
lines changed- mysql-test/suite/innodb_fts
- r
- t
- storage/innobase
- fts
- include
- row
6 files changed
+54
-37
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1485 | 1485 | | |
1486 | 1486 | | |
1487 | 1487 | | |
1488 | | - | |
1489 | | - | |
1490 | | - | |
1491 | | - | |
1492 | | - | |
1493 | | - | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
1494 | 1493 | | |
1495 | | - | |
1496 | | - | |
| 1494 | + | |
| 1495 | + | |
1497 | 1496 | | |
1498 | | - | |
1499 | 1497 | | |
1500 | 1498 | | |
1501 | 1499 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | | - | |
191 | | - | |
| 190 | + | |
| 191 | + | |
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
| 73 | + | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | 118 | | |
140 | | - | |
| 119 | + | |
141 | 120 | | |
142 | 121 | | |
143 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4476 | 4476 | | |
4477 | 4477 | | |
4478 | 4478 | | |
4479 | | - | |
| 4479 | + | |
4480 | 4480 | | |
4481 | 4481 | | |
4482 | 4482 | | |
4483 | 4483 | | |
4484 | 4484 | | |
| 4485 | + | |
| 4486 | + | |
| 4487 | + | |
| 4488 | + | |
| 4489 | + | |
| 4490 | + | |
| 4491 | + | |
| 4492 | + | |
| 4493 | + | |
| 4494 | + | |
| 4495 | + | |
| 4496 | + | |
| 4497 | + | |
| 4498 | + | |
| 4499 | + | |
| 4500 | + | |
| 4501 | + | |
| 4502 | + | |
4485 | 4503 | | |
4486 | | - | |
| 4504 | + | |
4487 | 4505 | | |
4488 | 4506 | | |
4489 | 4507 | | |
| |||
0 commit comments