1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-05 13:16:09 +03:00

MDEV-32050: Look up tables in the purge coordinator

The InnoDB table lookup in purge worker threads is a bottleneck that can
degrade a slow shutdown to utilize less than 2 threads. Let us fix that
bottleneck by constructing a local lookup table that does not require any
synchronization while the undo log records of the current batch
are being processed.

TRX_PURGE_TABLE_BUCKETS: The initial number of std::unordered_map
hash buckets used during a purge batch. This could avoid some
resizing and rehashing in trx_purge_attach_undo_recs().

purge_node_t::tables: A lookup table from table ID to an already
looked up and locked table. Replaces many fields.

trx_purge_attach_undo_recs(): Look up each table in the purge batch
only once.

trx_purge(): Close all tables and release MDL at the end of the batch.

trx_purge_table_open(), trx_purge_table_acquire(): Open a table in purge
and acquire a metadata lock on it. This replaces
dict_table_open_on_id<true>() and dict_acquire_mdl_shared().

purge_sys_t::close_and_reopen(): In case of an MDL conflict, close and
reopen all tables that are covered by the current purge batch.
It may be that some of the tables have been dropped meanwhile and can
be ignored. This replaces wait_SYS() and wait_FTS().

row_purge_parse_undo_rec(): Make purge_coordinator_task issue a
MDL warrant to any purge_worker_task which might need it
when innodb_purge_threads>1.

purge_node_t::end(): Clear the MDL warrant.

Reviewed by: Vladislav Lesin and Vladislav Vaintroub
This commit is contained in:
Marko Mäkelä
2023-10-25 10:08:20 +03:00
parent 39bb5ebb85
commit 88733282fb
19 changed files with 344 additions and 308 deletions

View File

@@ -6,6 +6,10 @@
--source include/big_test.inc
let $MYSQLD_DATADIR= `select @@datadir`;
SET GLOBAL innodb_max_purge_lag_wait=0;
connect (stop_purge,localhost,root);
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connection default;
#
# Test for BUG# 12739098, check whether trx->error_status is reset on error.
@@ -155,6 +159,7 @@ SET DEBUG_SYNC='now SIGNAL log2';
--connection con1
reap;
--disconnect con1
--disconnect stop_purge
--connection default
SET DEBUG_SYNC='RESET';
DROP TABLE t1;