mirror of
https://github.com/MariaDB/server.git
synced 2025-11-03 04:16:13 +01:00
The MDL_BACKUP_COMMIT lock used in handler.cc:ha_commit_trans() that is used to block commits as part of FLUSH TABLES WITH READ LOCK and BACKUP STAGE BLOCK_COMMIT can have a notable performance impact We need the commit block to be able to ensure consistent backups. The purpose of this commit is to instead of taking an expensive MDL lock, to protect each commit for a unlikely backup or FTWRL, we would instead add markers to threads that are doing a commit and when BLOCK_COMMIT or a FTWRL lock is used we would do slightly more work to ensure that all threads are taking MDL locks before taking the requested lock. When backup and FTRWL are not running we are now incrementing a global variable and setting a marker in the THD to signal that the thread is in the 'protected commit code block'. When FTWRL or BACKUP STAGE START is executed we enable MDL locking for commits and wait until all threads are outside of the protected block before continuing. When FTWRL and BACKUP STAGE end, we mark that MDL protecting is not anymore needed. The effect is that we change a MDL lock to two atomic increments and two memory assignments and one extra if. This speeds up commits but causes FTWRL and BACKUP STAGE START to be slower to start as they have to wait for active commits to complete. Most of the new logic can be found in the functions: enable_backup_commit_locks(), protect_against_backup() and unprotect_against_backup(). Other things: - The changes in the tests where because BACKUP STAGE START will now block if there are threads inside the 'protected commit block'. Before we waited in the test for BACKUP STAGE BLOCK COMMIT. I have now changed the tests to either wait for BACKUP STAGE START or by doing BACKUP STAGE START early and wait for BACKUP STAGE COMMIT. - Added MDL_request mdl_backup to THD to avoid initializing a new MDL_request for each commit and to simplify some code. This added 448 bytes to the THD. |
||
|---|---|---|
| .. | ||
| archive | ||
| atomic | ||
| binlog | ||
| binlog_encryption | ||
| client | ||
| compat | ||
| csv | ||
| encryption | ||
| engines | ||
| federated | ||
| funcs_1 | ||
| funcs_2 | ||
| galera | ||
| galera_3nodes | ||
| galera_3nodes_sr | ||
| galera_sr | ||
| gcol | ||
| handler | ||
| heap | ||
| innodb | ||
| innodb_fts | ||
| innodb_gis | ||
| innodb_i_s | ||
| innodb_zip | ||
| jp | ||
| json | ||
| large_tests | ||
| maria | ||
| mariabackup | ||
| mtr/t | ||
| mtr2 | ||
| multi_source | ||
| optimizer_unfixed_bugs | ||
| parts | ||
| perfschema | ||
| perfschema_stress | ||
| period | ||
| plugins | ||
| roles | ||
| rpl | ||
| s3 | ||
| sql_sequence | ||
| storage_engine | ||
| stress | ||
| sys_vars | ||
| sysschema | ||
| unit | ||
| vcol | ||
| versioning | ||
| wsrep | ||