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
Vlad Lesin a6f258e47f MDEV-20605 Awaken transaction can miss inserted by other transaction records due to wrong persistent cursor restoration
Backported from 10.5 20e9e804c1 and
5948d7602e.

sel_restore_position_for_mysql() moves forward persistent cursor
position after btr_pcur_restore_position() call if cursor relative position
is BTR_PCUR_ON and the cursor points to the record with NOT the same field
values as in a stored record(and some other not important for this case
conditions).

It was done because btr_pcur_restore_position() sets
page_cur_mode_t mode  to PAGE_CUR_LE for cursor->rel_pos ==  BTR_PCUR_ON
before opening cursor. So we are searching for the record less or equal
to stored one. And if the found record is not equal to stored one, then
it is less and we need to move cursor forward.

But there can be a situation when the stored record was purged, but the
new one with the same key but different value was inserted while
row_search_mvcc() was suspended. In this case, when the thread is
awaken, it will invoke sel_restore_position_for_mysql(), which, in turns,
invoke btr_pcur_restore_position(), which will return false because found
record don't match stored record, and
sel_restore_position_for_mysql() will move forward cursor position.

The above can lead to the case when awaken row_search_mvcc() do not see
records inserted by other transactions while it slept. The mtr test case
shows the example how it can be.

The fix is to return special value from persistent cursor restoring
function which would notify its caller that uniq fields of restored
record and stored record are the same, and in this case
sel_restore_position_for_mysql() don't move cursor forward.

Delete-marked records are correctly processed in row_search_mvcc().
Non-unique secondary indexes are "uniquified" by adding the PK, the
index->n_uniq should then be index->n_fields. So there is no need in
additional checks in the fix.

If transaction's readview can't see the changes made in secondary index
record, it requests clustered index record in row_search_mvcc() to check
its transaction id and get the correspondent record version. After this
row_search_mvcc() commits mtr to preserve clustered index latching
order, and starts mtr. Between those mtr commit and start secondary
index pages are unlatched, and purge has the ability to remove stored in
the cursor record, what causes rows duplication in result set for
non-locking reads, as cursor position is restored to the previously
visited record.

To solve this the changes are just switched off for non-locking reads,
it's quite simple solution, besides the changes don't make sense for
non-locking reads.

The more complex and effective from performance perspective solution is
to create mtr savepoint before clustered record requesting and rolling
back to that savepoint after that. See MDEV-27557.

One more solution is to have per-record transaction id for secondary
indexes. See MDEV-17598.

If any of those is implemented, just remove select_lock_type argument in
sel_restore_position_for_mysql().
2022-02-21 12:49:54 +03:00
BUILD MDEV 22785 Crash with prepared statements and NEXTVAL() 2021-08-26 07:07:46 +03:00
client MDEV-27691: make working view-protocol 2022-02-16 13:06:23 +07:00
cmake Merge branch '10.2' into 10.3 2022-01-29 15:41:05 +01:00
dbug Merge 10.2 into 10.3 2021-05-24 09:38:49 +03:00
debian Remove --upgrade-info option from mysql_upgrade 2022-01-27 14:52:08 +02:00
Docs
extra Merge branch '10.2' into 10.3 2022-01-29 15:41:05 +01:00
include MDEV-27730 Add PLUGIN_VAR_DEPRECATED flag to plugin variables 2022-02-18 13:10:20 +09:00
libmariadb@f6c3d9fd2a new CC 2022-01-26 10:42:01 +01:00
libmysqld Merge branch '10.2' into 10.3 2022-01-29 15:41:05 +01:00
libservices
man Merge 10.2 into 10.3 2022-02-17 10:53:58 +02:00
mysql-test MDEV-20605 Awaken transaction can miss inserted by other transaction records due to wrong persistent cursor restoration 2022-02-21 12:49:54 +03:00
mysys Merge branch 10.2 into 10.3 2021-12-23 14:14:04 +01:00
mysys_ssl Merge branch '10.2' into 10.3 2022-01-29 15:41:05 +01:00
pcre Merge branch '10.2' into 10.3 2021-07-29 13:51:02 +02:00
plugin Merge branch '10.2' into 10.3 2022-01-29 15:41:05 +01:00
randgen/conf
scripts Merge branch '10.2' into 10.3 2022-02-10 20:23:56 +01:00
sql MDEV-27730 Add PLUGIN_VAR_DEPRECATED flag to plugin variables 2022-02-18 13:10:20 +09:00
sql-bench
sql-common Merge branch '10.2' into 10.3 2020-09-28 17:27:42 +05:30
storage MDEV-20605 Awaken transaction can miss inserted by other transaction records due to wrong persistent cursor restoration 2022-02-21 12:49:54 +03:00
strings Merge branch '10.2' into 10.3 2022-01-29 15:41:05 +01:00
support-files Merge 10.2 into 10.3 2022-02-17 10:53:58 +02:00
tests Merge branch '10.2' into 10.3 2022-01-29 15:41:05 +01:00
unittest Merge branch '10.2' into 10.3 2021-12-06 22:23:07 +01:00
vio Merge branch 10.2 into 10.3 2021-12-23 14:14:04 +01:00
win Merge 10.2 into 10.3 2021-11-17 13:55:54 +02:00
wsrep cleanup: use predefined CMAKE_DL_LIBS 2020-10-23 13:37:26 +02:00
zlib Merge branch '10.2' into 10.3 2020-12-23 19:28:02 +01:00
.clang-format
.gitattributes MDEV-27494 Rename .ic files to .inl 2022-01-17 16:41:51 +01:00
.gitignore Merge 10.2 into 10.3 2021-10-13 11:38:21 +03:00
.gitmodules
.travis.compiler.sh
.travis.yml travis: update osx to xcode12u in attempt to solve openssl build failure 2020-09-02 11:23:18 +10:00
appveyor.yml Windows, appveyor - use VS2022 2022-01-09 13:56:50 +01:00
BUILD-CMAKE
CMakeLists.txt Merge branch '10.2' into 10.3 2022-01-29 15:41:05 +01:00
config.h.cmake Merge 10.2 into 10.3 2021-03-27 16:11:26 +02:00
configure.cmake improve checks for libatomic linking 2021-12-30 16:20:29 +11:00
COPYING
CREDITS Update sponsors 2021-03-12 07:02:29 +11:00
INSTALL-SOURCE
INSTALL-WIN-SOURCE
KNOWN_BUGS.txt
README.md Remove Travis CI status 2021-06-21 08:18:34 +03:00
THIRDPARTY
VERSION bump the VERSION 2022-02-12 15:43:53 -05:00

Code status:

  • 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