You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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(). These handles are stored in a new
purge_table_ctx_t structure within each purge_node_t->tables map,
keyed by table_id. When worker thread needs TABLE* for virtual column
computation, it fetches the TABLE* from purge_node_t->tables.
purge_table_ctx_t(): Structure to hold dict_table_t*, MDL_ticket* and
TABLE* for each table during batch processing. TABLE* is being opened
only when virtual index exists for the table.
innobase_open_purge_table(), innobase_close_thread_table(): wrapper to
make open_purge_table(), close_thread_tables() accessible from InnoDB
purge subsystem
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(): Skip innobase_reset_background_thd() for the coordinator
thread to prevent the premature table closure
trx_purge(): Closes the coordinator's TABLE* objects after all workers
are completed
0 commit comments