MDEV-28709 unexpected X lock on Supremum in READ COMMITTED

The lock is created during page splitting after moving records and
locks(lock_move_rec_list_(start|end)()) to the new page, and inheriting
the locks to the supremum of left page from the successor of the infimum
on right page.

There is no need in such inheritance for READ COMMITTED isolation level
and not-gap locks, so the fix is to add the corresponding condition in
gap lock inheritance function.

One more fix is to forbid gap lock inheritance if XA was prepared. Use the
most significant bit of trx_t::n_ref to indicate that gap lock inheritance
is forbidden. This fix is based on
mysql/mysql-server@b063e52a83
This commit is contained in:
Vlad Lesin 2022-06-29 17:03:56 +03:00
commit 8128a46827
5 changed files with 207 additions and 57 deletions

View file

@ -412,7 +412,8 @@ void trx_t::free()
mod_tables.clear();
MEM_NOACCESS(&n_ref, sizeof n_ref);
MEM_NOACCESS(&skip_lock_inheritance_and_n_ref,
sizeof skip_lock_inheritance_and_n_ref);
/* do not poison mutex */
MEM_NOACCESS(&id, sizeof id);
MEM_NOACCESS(&state, sizeof state);
@ -518,6 +519,7 @@ inline void trx_t::release_locks()
}
lock.table_locks.clear();
reset_skip_lock_inheritance();
}
/** At shutdown, frees a transaction object. */