mariadb/mysql-test/suite
Sergey Vojtovich 23566b6924 MDEV-19749 - MDL scalability regression after backup locks
Statements that intend to modify data have to acquire protection
against ongoing backup. Prior to backup locks, protection against
FTWRL was acquired in form of 2 shared metadata locks of GLOBAL
(global read lock) and COMMIT namespaces. These two namespaces
were separate entities, they didn't share data structures and
locking primitives. And thus they were separate contention
points.

With backup locks, introduced by 7a9dfdd, these namespaces were
combined into a single BACKUP namespace. It became a single
contention point, which doubled load on BACKUP namespace data
structures and locking primitives compared to GLOBAL and COMMIT
namespaces. In other words system throughput has halved.

MDL fast lanes solve this problem by allowing multiple contention
points for single MDL_lock. Fast lane is scalable multi-instance
registry for leightweight locks. Internally it is just a list of
granted tickets, close counter and a mutex.

Number of fast lanes (or contention points) is defined by the
metadata_locks_instances system variable. Value of 1 disables fast
lanes and lock requests are served by conventional MDL_lock data
structures.

Since fast lanes allow arbitrary number of contention points, they
outperform pre-backup locks GLOBAL and COMMIT.

Fast lanes are enabled only for BACKUP namespace. Support for other
namespaces is to be implemented separately.

Lock types are divided in 2 categories: lightweight and heavyweight.

Lightweight lock types represent DML: MDL_BACKUP_DML,
MDL_BACKUP_TRANS_DML, MDL_BACKUP_SYS_DML, MDL_BACKUP_DDL,
MDL_BACKUP_ALTER_COPY, MDL_BACKUP_COMMIT. They are fully compatible
with each other. Normally served by corresponding fast lane, which is
determined by thread_id % metadata_locks_instances.

Heavyweight lock types represent ongoing backup: MDL_BACKUP_START,
MDL_BACKUP_FLUSH, MDL_BACKUP_WAIT_FLUSH, MDL_BACKUP_WAIT_DDL,
MDL_BACKUP_WAIT_COMMIT, MDL_BACKUP_FTWRL1, MDL_BACKUP_FTWRL2,
MDL_BACKUP_BLOCK_DDL. These locks are always served by conventional
MDL_lock data structures. Whenever such lock is requested, fast
lanes are closed and all tickets registered in fast lanes are
moved to conventional MDL_lock data structures. Until such locks
are released or aborted, lightweight lock requests are served by
conventional MDL_lock data structures.

Strictly speaking moving tickets from fast lanes to conventional
MDL_lock data structures is not required. But it allows to reduce
complexity and keep intact methods like: MDL_lock::visit_subgraph(),
MDL_lock::notify_conflicting_locks(), MDL_lock::reschedule_waiters(),
MDL_lock::can_grant_lock().

It is not even required to register tickets in fast lanes. They
can be implemented basing on an atomic variable that holds two
counters: granted lightweight locks and granted/waiting heavyweight
locks. Similarly to MySQL solution, which roughly speaking has
"single atomic fast lane". However it appears to be it won't bring
any better performance, while code complexity is going to be much
higher.
2025-06-06 10:57:29 +04:00
..
archive MDEV-36050 DATA/INDEX DIRECTORY handling is inconsistent 2025-04-18 09:41:23 +02:00
atomic Merge 11.4 into 11.8 2025-04-02 14:07:01 +03:00
binlog Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
binlog_encryption Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
client Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
compat Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
csv Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
encryption Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
engines Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
events Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
federated Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
funcs_1 Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
funcs_2 Merge 11.4 into 11.8 2025-04-02 14:07:01 +03:00
galera Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
galera_3nodes Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
galera_3nodes_sr Merge 11.4 into 11.8 2025-04-02 14:07:01 +03:00
galera_sr Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
gcol Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
handler Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
heap Merge branch '11.4' into 11.7 2025-02-06 16:46:36 +01:00
innodb Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
innodb_fts Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
innodb_gis Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
innodb_i_s
innodb_zip Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
jp Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
json Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
large_tests fix failing large_tests.maria_recover_encrypted 2024-04-22 18:38:39 +02:00
maria Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
mariabackup Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
merge Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
mtr/t Remove dates from all rdiff files 2025-01-05 16:40:11 +02:00
mtr2
multi_source MDEV-36340: Reset Connects_Tried with Master_Retry_Count=X 2025-04-22 12:05:27 -06:00
optimizer_unfixed_bugs
parts Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
perfschema Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
perfschema_stress
period Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
plugins Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
roles Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
rpl Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
s3 Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
sql_sequence Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
storage_engine
stress MDEV-34453 Trying to read 16384 bytes at 70368744161280 outside the bounds of the file: ./ibdata1 2024-09-20 20:26:43 +05:30
sys_vars MDEV-19749 - MDL scalability regression after backup locks 2025-06-06 10:57:29 +04:00
sysschema Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
unit Merge branch '11.4' into 11.5 2024-08-05 17:50:18 +02:00
vcol Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
versioning Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
wsrep Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00