MariaDB server is a community developed fork of MySQL server. Started by core members of the original MySQL team, MariaDB actively works with outside developers to deliver the most featureful, stable, and sanely licensed open SQL server in the industry.
  • MariaDB\ 71.8%
  • C++ 16.4%
  • C 10.4%
  • Shell 0.5%
  • Perl 0.4%
  • Other 0.3%
Find a file
Marko Mäkelä c5fd9aa562 MDEV-25919: Lock tables before acquiring dict_sys.latch
In commit 1bd681c8b3 (MDEV-25506 part 3)
we introduced a "fake instant timeout" when a transaction would wait
for a table or record lock while holding dict_sys.latch. This prevented
a deadlock of the server but could cause bogus errors for operations
on the InnoDB persistent statistics tables.

A better fix is to ensure that whenever a transaction is being
executed in the InnoDB internal SQL parser (which will for now
require dict_sys.latch to be held), it will already have acquired
all locks that could be required for the execution. So, we will
acquire the following locks upfront, before acquiring dict_sys.latch:

(1) MDL on the affected user table (acquired by the SQL layer)
(2) If applicable (not for RENAME TABLE): InnoDB table lock
(3) If persistent statistics are going to be modified:
(3.a) MDL_SHARED on mysql.innodb_table_stats, mysql.innodb_index_stats
(3.b) exclusive table locks on the statistics tables
(4) Exclusive table locks on the InnoDB data dictionary tables
(not needed in ANALYZE TABLE and the like)

Note: Acquiring exclusive locks on the statistics tables may cause
more locking conflicts between concurrent DDL operations.
Notably, RENAME TABLE will lock the statistics tables
even if no persistent statistics are enabled for the table.

DROP DATABASE will only acquire locks on statistics tables if
persistent statistics are enabled for the tables on which the
SQL layer is invoking ha_innobase::delete_table().
For any "garbage collection" in innodb_drop_database(), a timeout
while acquiring locks on the statistics tables will result in any
statistics not being deleted for any tables that the SQL layer
did not know about.

If innodb_defragment=ON, information may be written to the statistics
tables even for tables for which InnoDB persistent statistics are
disabled. But, DROP TABLE will no longer attempt to delete that
information if persistent statistics are not enabled for the table.

This change should also fix the hangs related to InnoDB persistent
statistics and STATS_AUTO_RECALC (MDEV-15020) as well as
a bug that running ALTER TABLE on the statistics tables
concurrently with running ALTER TABLE on InnoDB tables could
cause trouble.

lock_rec_enqueue_waiting(), lock_table_enqueue_waiting():
Do not issue a fake instant timeout error when the transaction
is holding dict_sys.latch. Instead, assert that the dict_sys.latch
is never being held here.

lock_sys_tables(): A new function to acquire exclusive locks on all
dictionary tables, in case DROP TABLE or similar operation is
being executed. Locking non-hard-coded tables is optional to avoid
a crash in row_merge_drop_temp_indexes(). The SYS_VIRTUAL table was
introduced in MySQL 5.7 and MariaDB Server 10.2. Normally, we require
all these dictionary tables to exist before executing any DDL, but
the function row_merge_drop_temp_indexes() is an exception.
When upgrading from MariaDB Server 10.1 or MySQL 5.6 or earlier,
the table SYS_VIRTUAL would not exist at this point.

ha_innobase::commit_inplace_alter_table(): Invoke
log_write_up_to() while not holding dict_sys.latch.

dict_sys_t::remove(), dict_table_close(): No longer try to
drop index stubs that were left behind by aborted online ADD INDEX.
Such indexes should be dropped from the InnoDB data dictionary by
row_merge_drop_indexes() as part of the failed DDL operation.
Stubs for aborted indexes may only be left behind in the
data dictionary cache.

dict_stats_fetch_from_ps(): Use a normal read-only transaction.

ha_innobase::delete_table(), ha_innobase::truncate(), fts_lock_table():
While waiting for purge to stop using the table,
do not hold dict_sys.latch.

ha_innobase::delete_table(): Implement a work-around for the rollback
of ALTER TABLE...ADD PARTITION. MDL_EXCLUSIVE would not be held if
ALTER TABLE hits lock_wait_timeout while trying to upgrade the MDL
due to a conflicting LOCK TABLES, such as in the first ALTER TABLE
in the test case of Bug#53676 in parts.partition_special_innodb.
Therefore, we must explicitly stop purge, because it would not be
stopped by MDL.

dict_stats_func(), btr_defragment_chunk(): Allocate a THD so that
we can acquire MDL on the InnoDB persistent statistics tables.

mysqltest_embedded: Invoke ha_pre_shutdown() before free_used_memory()
in order to avoid ASAN heap-use-after-free related to acquire_thd().

trx_t::dict_operation_lock_mode: Changed the type to bool.

row_mysql_lock_data_dictionary(), row_mysql_unlock_data_dictionary():
Implemented as macros.

rollback_inplace_alter_table(): Apply an infinite timeout to lock waits.

innodb_thd_increment_pending_ops(): Wrapper for
thd_increment_pending_ops(). Never attempt async operation for
InnoDB background threads, such as the trx_t::commit() in
dict_stats_process_entry_from_recalc_pool().

lock_sys_t::cancel(trx_t*): Make dictionary transactions immune to KILL.

lock_wait(): Make dictionary transactions immune to KILL, and to
lock wait timeout when waiting for locks on dictionary tables.

parts.partition_special_innodb: Use lock_wait_timeout=0 to instantly
get ER_LOCK_WAIT_TIMEOUT.

main.mdl: Filter out MDL on InnoDB persistent statistics tables

Reviewed by: Thirunarayanan Balathandayuthapani
2021-08-31 13:54:44 +03:00
.github Add Pull Request template file to the MariaDB/server repository 2021-05-27 16:28:28 +03:00
BUILD Merge 10.3 into 10.4 2021-08-31 09:22:21 +03:00
client MDEV-25919: Lock tables before acquiring dict_sys.latch 2021-08-31 13:54:44 +03:00
cmake Merge 10.5 into 10.6 2021-08-31 11:00:41 +03:00
dbug MDEV-25602 get rid of __WIN__ in favor of standard _WIN32 2021-06-06 13:21:03 +02:00
debian Merge 10.5 into 10.6 2021-08-23 11:21:33 +03:00
Docs
extra Merge 10.5 into 10.6 2021-08-31 11:00:41 +03:00
include Merge 10.5 into 10.6 2021-08-31 11:00:41 +03:00
libmariadb@fc25d79083 Merge 10.5 into 10.6 2021-08-31 11:00:41 +03:00
libmysqld fix main.lock_kill crashes in --ps --embed 2021-06-30 09:34:26 +02:00
libservices
man Merge 10.5 into 10.6 2021-05-18 11:13:45 +03:00
mysql-test MDEV-25919: Lock tables before acquiring dict_sys.latch 2021-08-31 13:54:44 +03:00
mysys Merge 10.5 into 10.6 2021-08-31 11:00:41 +03:00
mysys_ssl
plugin Merge 10.5 into 10.6 2021-08-26 10:20:17 +03:00
randgen/conf
scripts Merge 10.5 into 10.6 2021-08-31 11:00:41 +03:00
sql MDEV-25919: Lock tables before acquiring dict_sys.latch 2021-08-31 13:54:44 +03:00
sql-bench MDEV-24854: Change innodb_flush_method=O_DIRECT by default 2021-02-20 11:58:58 +02:00
sql-common Change CHARSET_INFO character set and collaction names to LEX_CSTRING 2021-05-19 22:54:07 +02:00
storage MDEV-25919: Lock tables before acquiring dict_sys.latch 2021-08-31 13:54:44 +03:00
strings MDEV-25602 get rid of __WIN__ in favor of standard _WIN32 2021-06-06 13:21:03 +02:00
support-files Merge branch '10.5' into 10.6 2021-08-02 10:11:41 +02:00
tests Merge 10.5 to 10.6 2021-08-19 12:25:00 +03:00
tpool Merge 10.5 into 10.6 2021-06-18 09:16:20 +03:00
unittest MDEV-25602 get rid of __WIN__ in favor of standard _WIN32 2021-06-06 13:21:03 +02:00
vio MDEV-25602 get rid of __WIN__ in favor of standard _WIN32 2021-06-06 13:21:03 +02:00
win Merge 10.5 into 10.6 2021-06-09 16:50:58 +03:00
wsrep-lib@c45b1eff94 Update result files for Galera library 26.4.9 2021-07-27 10:34:45 +03:00
zlib
.clang-format
.gitattributes .gitattributes - correct language detection 2021-01-15 18:29:35 +11:00
.gitignore Merge 10.5 into 10.6 2021-07-02 17:00:05 +03:00
.gitlab-ci.yml Implement simple Gitlab-CI pipeline for MariaDB with RPM builds 2021-07-14 10:37:11 +03:00
.gitmodules
.travis.compiler.sh
.travis.yml MDEV-25288 follow-up: Remove traces of unstable-tests 2021-06-11 15:59:02 +03:00
appveyor.yml MDEV-25288 follow-up: Remove traces of unstable-tests 2021-06-11 15:59:02 +03:00
BUILD-CMAKE
CMakeLists.txt Merge branch '10.5' into 10.6 2021-08-02 10:11:41 +02:00
config.h.cmake MDEV-25602 get rid of __WIN__ in favor of standard _WIN32 2021-06-06 13:21:03 +02:00
configure.cmake Merge branch '10.5' into 10.6 2021-08-02 10:11:41 +02:00
CONTRIBUTING.md
COPYING
CREDITS Update sponsors 2021-03-12 07:02:29 +11:00
INSTALL-SOURCE
INSTALL-WIN-SOURCE
KNOWN_BUGS.txt
README.md Merge 10.4 into 10.5 2021-06-21 14:22:22 +03:00
THIRDPARTY
VERSION bump the VERSION 2021-08-05 10:42:39 -04:00

Code status:

  • Appveyor CI status ci.appveyor.com

MariaDB: The open source relational database

MariaDB was designed as a drop-in replacement of MySQL(R) with more features, new storage engines, fewer bugs, and better performance.

MariaDB is brought to you by the MariaDB Foundation and the MariaDB Corporation. Please read the CREDITS file for details about the MariaDB Foundation, and who is developing MariaDB.

MariaDB is developed by many of the original developers of MySQL who now work for the MariaDB Corporation, the MariaDB Foundation and by many people in the community.

MySQL, which is the base of MariaDB, is a product and trademark of Oracle Corporation, Inc. For a list of developers and other contributors, see the Credits appendix. You can also run 'SHOW authors' to get a list of active contributors.

A description of the MariaDB project and a manual can be found at:

https://mariadb.org

https://mariadb.com/kb/en/

https://mariadb.com/kb/en/mariadb-vs-mysql-features/

https://mariadb.com/kb/en/mariadb-versus-mysql-compatibility/

https://mariadb.com/kb/en/new-and-old-releases/

Help

More help is available from the Maria Discuss mailing list https://launchpad.net/~maria-discuss, MariaDB's Zulip instance, https://mariadb.zulipchat.com/ and the #maria IRC channel on Freenode.

Live QA for beginner contributors

MariaDB has a dedicated time each week when we answer new contributor questions live on Zulip and IRC. From 8:00 to 10:00 UTC on Mondays, and 10:00 to 12:00 UTC on Thursdays, anyone can ask any questions theyd like, and a live developer will be available to assist.

New contributors can ask questions any time, but we will provide immediate feedback during that interval.

Licensing


NOTE:

MariaDB is specifically available only under version 2 of the GNU General Public License (GPLv2). (I.e. Without the "any later version" clause.) This is inherited from MySQL. Please see the README file in the MySQL distribution for more information.

License information can be found in the COPYING file. Third party license information can be found in the THIRDPARTY file.


Bug Reports

Bug and/or error reports regarding MariaDB should be submitted at: https://jira.mariadb.org

For reporting security vulnerabilities see: https://mariadb.org/about/security-policy/

The code for MariaDB, including all revision history, can be found at: https://github.com/MariaDB/server