Commit 3ef5939
committed
MDEV-39261 MariaDB crash on startup in presence of indexed virtual columns
Problem:
========
A single InnoDB purge worker thread can process undo logs from different
tables within the same batch. But get_purge_table(), open_purge_table()
incorrectly assumes that a 1:1 relationship between a purge worker thread
and a table within a single batch. Based on this wrong assumtion,
InnoDB attempts to reuse TABLE objects cached in thd->open_tables for
virtual column computation.
1) Purge worker opens Table A and caches the TABLE pointer in thd->open_tables.
2) Same purge worker moves to Table B in the same batch, get_purge_table()
retrieves the cached pointer for Table A instead of opening Table B.
3) Because innobase::open() is ignored for Table B, the virtual column
template is never initialized.
4) virtual column computation for Table B aborts the server
Solution:
========
The purge coordinator thread now opens both InnoDB dict_table_t* and
MariaDB TABLE* handles during batch preparation in
trx_purge_attach_undo_recs(). purge_node_t::tables now stores only
std::pair<dict_table_t*, TABLE*>. When worker thread
needs TABLE* for virtual column computation, it fetches
the TABLE* from purge_node_t->tables.
trx_purge_table_open(): Modified to open TABLE* using the
coordinator's MDL ticket
open_purge_table(): Accept and use the MDL ticket from coordinator thread
purge_sys_t::coordinator_thd: To track the coordinator thread in purge
subsystem
purge_node_t::end(): To prevent premature table closure when the coordinator
acts as a worker and skips innobase_reset_background_thd()
purge_sys_t::close_and_reopen(): Properly handles retry logic by clearing
all table state and reopening the table. Uses mdl_map for maintaining
mdl_tickets for each table id
trx_purge_close_tables(): Now accepts mdl_map parameter to
release MDL tickets from the coordinator's map after closing tables
trx_purge(): MDL tickets are now stored in a local mdl_map instead of
purge_node_t. Closes the coordinator's TABLE* objects after all workers
are completed
Declared open_purge_table() and close_thread_tables() in trx0purge.cc1 parent 8229217 commit 3ef5939
File tree
16 files changed
+276
-153
lines changed- mysql-test/suite
- gcol
- r
- t
- vcol
- r
- t
- sql
- storage/innobase
- dict
- handler
- include
- row
- trx
16 files changed
+276
-153
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
52 | 51 | | |
53 | 52 | | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
306 | | - | |
307 | 306 | | |
308 | | - | |
309 | 307 | | |
| 308 | + | |
| 309 | + | |
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
313 | | - | |
314 | 313 | | |
315 | | - | |
316 | 314 | | |
| 315 | + | |
| 316 | + | |
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
321 | | - | |
322 | 321 | | |
| 322 | + | |
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
| |||
523 | 523 | | |
524 | 524 | | |
525 | 525 | | |
526 | | - | |
527 | 526 | | |
528 | 527 | | |
529 | 528 | | |
| 529 | + | |
530 | 530 | | |
531 | 531 | | |
532 | 532 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
356 | 357 | | |
357 | 358 | | |
358 | 359 | | |
| 360 | + | |
359 | 361 | | |
360 | 362 | | |
361 | 363 | | |
| 364 | + | |
362 | 365 | | |
363 | 366 | | |
364 | 367 | | |
365 | 368 | | |
| 369 | + | |
366 | 370 | | |
367 | 371 | | |
368 | 372 | | |
| |||
537 | 541 | | |
538 | 542 | | |
539 | 543 | | |
| 544 | + | |
540 | 545 | | |
541 | 546 | | |
542 | 547 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
820 | 820 | | |
821 | 821 | | |
822 | 822 | | |
823 | | - | |
| 823 | + | |
824 | 824 | | |
825 | 825 | | |
826 | 826 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5024 | 5024 | | |
5025 | 5025 | | |
5026 | 5026 | | |
5027 | | - | |
| 5027 | + | |
| 5028 | + | |
5028 | 5029 | | |
5029 | 5030 | | |
5030 | | - | |
5031 | 5031 | | |
5032 | 5032 | | |
5033 | 5033 | | |
| |||
5038 | 5038 | | |
5039 | 5039 | | |
5040 | 5040 | | |
| 5041 | + | |
5041 | 5042 | | |
5042 | 5043 | | |
5043 | 5044 | | |
| |||
5050 | 5051 | | |
5051 | 5052 | | |
5052 | 5053 | | |
5053 | | - | |
5054 | | - | |
5055 | | - | |
5056 | | - | |
5057 | | - | |
5058 | | - | |
5059 | | - | |
5060 | 5054 | | |
5061 | 5055 | | |
5062 | 5056 | | |
| |||
5217 | 5211 | | |
5218 | 5212 | | |
5219 | 5213 | | |
| 5214 | + | |
| 5215 | + | |
5220 | 5216 | | |
5221 | 5217 | | |
5222 | 5218 | | |
5223 | 5219 | | |
| 5220 | + | |
5224 | 5221 | | |
5225 | 5222 | | |
5226 | 5223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
626 | 626 | | |
627 | 627 | | |
628 | 628 | | |
629 | | - | |
| 629 | + | |
630 | 630 | | |
631 | 631 | | |
632 | 632 | | |
633 | 633 | | |
634 | 634 | | |
635 | | - | |
| 635 | + | |
636 | 636 | | |
637 | 637 | | |
638 | 638 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | 127 | | |
129 | | - | |
130 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| |||
1785 | 1785 | | |
1786 | 1786 | | |
1787 | 1787 | | |
1788 | | - | |
1789 | | - | |
1790 | 1788 | | |
1791 | | - | |
1792 | 1789 | | |
1793 | 1790 | | |
1794 | 1791 | | |
| |||
8536 | 8533 | | |
8537 | 8534 | | |
8538 | 8535 | | |
8539 | | - | |
| 8536 | + | |
8540 | 8537 | | |
8541 | 8538 | | |
8542 | 8539 | | |
| |||
20071 | 20068 | | |
20072 | 20069 | | |
20073 | 20070 | | |
20074 | | - | |
20075 | | - | |
20076 | | - | |
20077 | | - | |
20078 | | - | |
20079 | | - | |
20080 | | - | |
20081 | | - | |
20082 | | - | |
20083 | | - | |
20084 | | - | |
20085 | | - | |
| 20071 | + | |
| 20072 | + | |
20086 | 20073 | | |
20087 | 20074 | | |
| 20075 | + | |
20088 | 20076 | | |
20089 | 20077 | | |
20090 | | - | |
| 20078 | + | |
20091 | 20079 | | |
20092 | 20080 | | |
20093 | 20081 | | |
20094 | 20082 | | |
20095 | | - | |
20096 | | - | |
20097 | | - | |
20098 | | - | |
20099 | | - | |
20100 | | - | |
20101 | 20083 | | |
20102 | 20084 | | |
20103 | 20085 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2551 | 2551 | | |
2552 | 2552 | | |
2553 | 2553 | | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
2554 | 2565 | | |
2555 | 2566 | | |
2556 | 2567 | | |
| |||
0 commit comments