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.
Find a file
Marko Mäkelä b07beff894 MDEV-15326: InnoDB: Failing assertion: !other_lock
MySQL 5.7.9 (and MariaDB 10.2.2) introduced a race condition
between InnoDB transaction commit and the conversion of implicit
locks into explicit ones.

The assertion failure can be triggered with a test that runs
3 concurrent single-statement transactions in a loop on a simple
table:

CREATE TABLE t (a INT PRIMARY KEY) ENGINE=InnoDB;
thread1: INSERT INTO t SET a=1;
thread2: DELETE FROM t;
thread3: SELECT * FROM t FOR UPDATE; -- or DELETE FROM t;

The failure scenarios are like the following:
(1) The INSERT statement is being committed, waiting for lock_sys->mutex.
(2) At the time of the failure, both the DELETE and SELECT transactions
are active but have not logged any changes yet.
(3) The transaction where the !other_lock assertion fails started
lock_rec_convert_impl_to_expl().
(4) After this point, the commit of the INSERT removed the transaction from
trx_sys->rw_trx_set, in trx_erase_lists().
(5) The other transaction consulted trx_sys->rw_trx_set and determined
that there is no implicit lock. Hence, it grabbed the lock.
(6) The !other_lock assertion fails in lock_rec_add_to_queue()
for the lock_rec_convert_impl_to_expl(), because the lock was 'stolen'.
This assertion failure looks genuine, because the INSERT transaction
is still active (trx->state=TRX_STATE_ACTIVE).

The problematic step (4) was introduced in
mysql/mysql-server@e27e0e0bb7
which fixed something related to MVCC (covered by the test
innodb.innodb-read-view). Basically, it reintroduced an error
that had been mentioned in an earlier commit
mysql/mysql-server@a17be6963f:
"The active transaction was removed from trx_sys->rw_trx_set prematurely."

Our fix goes along the following lines:

(a) Implicit locks will released by assigning
trx->state=TRX_STATE_COMMITTED_IN_MEMORY as the first step.
This transition will no longer be protected by lock_sys_t::mutex,
only by trx->mutex. This idea is by Sergey Vojtovich.
(b) We detach the transaction from trx_sys before starting to release
explicit locks.
(c) All callers of trx_rw_is_active() and trx_rw_is_active_low() must
recheck trx->state after acquiring trx->mutex.
(d) Before releasing any explicit locks, we will ensure that any activity
by other threads to convert implicit locks into explicit will have ceased,
by checking !trx_is_referenced(trx). There was a glitch
in this check when it was part of lock_trx_release_locks(); at the end
we would release trx->mutex and acquire lock_sys->mutex and trx->mutex,
and fail to recheck (trx_is_referenced() is protected by trx_t::mutex).
(e) Explicit locks can be released in batches (LOCK_RELEASE_INTERVAL=1000)
just like we did before.

trx_t::state: Document that the transition to COMMITTED is only
protected by trx_t::mutex, no longer by lock_sys_t::mutex.

trx_rw_is_active_low(), trx_rw_is_active(): Document that the transaction
state should be rechecked after acquiring trx_t::mutex.

trx_t::commit_state(): New function to change a transaction to committed
state, to release implicit locks.

trx_t::release_locks(): New function to release the explicit locks
after commit_state().

lock_trx_release_locks(): Move much of the logic to the caller
(which must invoke trx_t::commit_state() and trx_t::release_locks()
as needed), and assert that the transaction will have locks.

trx_get_trx_by_xid(): Make the parameter a pointer to const.

lock_rec_other_trx_holds_expl(): Recheck trx->state after acquiring
trx->mutex, and avoid a redundant lookup of the transaction.

lock_rec_queue_validate(): Recheck impl_trx->state while holding
impl_trx->mutex.

row_vers_impl_x_locked(), row_vers_impl_x_locked_low():
Document that the transaction state must be rechecked after
trx_mutex_enter().

trx_free_prepared(): Adjust for the changes to lock_trx_release_locks().
2019-09-04 09:42:38 +03:00
BUILD Updated BUILD/SETUP from MariaDB 10.5 2019-09-01 19:17:34 +03:00
client MDEV-20377: Fix uninitialized memory in mysqltest 2019-08-19 17:09:59 +03:00
cmake Merge 10.1 into 10.2 2019-08-28 15:23:21 +03:00
dbug Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
debian Updated mtr files to support different compiled in options 2019-09-01 19:17:35 +03:00
Docs MDEV-19563 Removed references to deprecated option innodb_locks_unsafe_for_binlog 2019-06-12 13:00:08 +03:00
extra MDEV-19740: Silence a bogus "may be uninitialized" warning 2019-08-15 15:58:37 +03:00
include Merge 10.1 into 10.2 2019-08-28 15:23:21 +03:00
libmariadb@544b6f1d12 C/C 2019-09-03 20:34:30 +02:00
libmysqld MDEV-18156 Assertion 0' failed or btr_validate_index(index, 0, false)' in row_upd_sec_index_entry or error code 126: Index is corrupted upon DELETE with PAD_CHAR_TO_FULL_LENGTH 2019-09-03 05:34:53 +04:00
libservices Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
man Merge 10.1 into 10.2 2019-05-28 15:56:24 +03:00
mysql-test MDEV-15326 preparation: Test slow shutdown after XA PREPARE 2019-09-04 09:42:38 +03:00
mysys Fix debug assert to match its intention. 2019-06-17 19:01:15 +01:00
mysys_ssl Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
pcre Fixed some compiler warnings 2019-09-01 19:17:34 +03:00
plugin Merge branch '10.1' into 10.2 2019-07-26 07:03:39 +02:00
randgen/conf
scripts Updated mtr files to support different compiled in options 2019-09-01 19:17:35 +03:00
sql MDEV-15326: InnoDB: Failing assertion: !other_lock 2019-09-04 09:42:38 +03:00
sql-bench Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
sql-common Merge 10.1 into 10.2 2019-08-20 09:15:28 +03:00
storage MDEV-15326: InnoDB: Failing assertion: !other_lock 2019-09-04 09:42:38 +03:00
strings Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
support-files Merge branch '10.1' into 10.2 2019-07-26 07:03:39 +02:00
tests Ensure that tests and programs can restore variables 2019-06-03 15:06:51 +03:00
unittest Fixed some errors & warnings found by clang 2019-08-08 23:08:23 +03:00
vio Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
win Merge branch '10.1' into 10.2 2019-07-26 07:03:39 +02:00
wsrep Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
zlib Merge remote-tracking branch 'connect/10.2' into 10.2 2019-08-30 16:52:43 +02:00
.clang-format MDEV-13631 Make use of clang-format 2019-06-12 22:36:43 +03:00
.gitattributes Merge branch '10.0' into 10.1 2018-05-05 14:01:59 +02:00
.gitignore Fixed dependency checking in some Galera tests 2019-07-18 14:56:39 +02:00
.gitmodules Use https instead of ssh(git@) for rocksdb submodule. 2016-11-15 10:00:19 -05:00
.travis.compiler.sh travis: add clang-5.0 2017-08-07 10:05:01 +04:00
.travis.yml travis: osx - xcode 8.3 -> 9.1 2017-10-31 11:21:28 +04:00
appveyor.yml Appveyor configuration and addition of badge 2019-05-09 10:56:15 +02:00
BUILD-CMAKE
CMakeLists.txt MDEV-20377: Introduce cmake -DWITH_MSAN:BOOL=ON 2019-08-19 20:56:26 +03:00
config.h.cmake Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
configure.cmake Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
COPYING Update FSF Address 2019-05-11 21:29:06 +03:00
CREDITS Update contributors 2018-09-10 16:47:44 +04:00
EXCEPTIONS-CLIENT MDEV-5645 MariaDB-5.5.35 - references are made to an "EXCEPTIONS-CLIENT" file but it does not exist 2014-05-31 13:18:56 +02:00
INSTALL-SOURCE Update AskMonty and Atlassian references to MariaDB 2016-03-08 15:24:01 +02:00
INSTALL-WIN-SOURCE Update AskMonty and Atlassian references to MariaDB 2016-03-08 15:24:01 +02:00
KNOWN_BUGS.txt
README.md Appveyor configuration and addition of badge 2019-05-09 10:56:15 +02:00
THIRDPARTY Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
VERSION bump the VERSION 2019-07-31 09:57:31 -04:00

Code status:

  • Travis CI status travis-ci.org (10.2 branch)
  • Appveyor CI status ci.appveyor.com

MariaDB: drop-in replacement for MySQL

MariaDB is 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. 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 Foundation and the MariaDB Corporation, 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-features/

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

As MariaDB is a full replacement of MySQL, the MySQL manual at http://dev.mysql.com/doc is generally applicable.

Help:

More help is available from the Maria Discuss mailing list https://launchpad.net/~maria-discuss and the #maria IRC channel on Freenode.

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/

Bugs in the MySQL code can also be submitted at: https://bugs.mysql.com

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


Code status:

  • tests status travis-ci.org (10.2 branch)