[MDEV-24324] Having an active XA transaction in THD:cleanup will release MDL locks too early. Created: 2020-12-01  Updated: 2020-12-01

Status: Open
Project: MariaDB Server
Component/s: XA
Affects Version/s: 10.4, 10.5, 10.6
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Michael Widenius Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-23484 Rollback unnecessarily acquires dict_... Closed
relates to MDEV-15532 XA: Assertion `!log->same_pk' failed ... Closed

 Description   

After the fix of MDEV-15532, 10.2 and 10.3 are fine.
However the new code in sql/xa.cc has the same issue and crash scenarios
as MDEV-15532 in the following scenario:

  • Start a XA transaction, put it in prepare phase
  • Start a normal transaction involving several tables
  • kill the connection

In this case the 10.4 code will in THD::cleanup() call
trans_xa_detach(), which will reset the transaction flags, and then
call release_transactional_locks().

The effect will be as in MDEV-15532: We have active transactions but
no MDL locks to protect against ALTER TABLE.

We can't ignore calling release_transactional_locks() in
THD::cleanup() after trans_xa_detach as in this case we have MDL locks
that will never be removed when THD disappears after cleanup().

One suggested fix is to move the transactional locks from THD to the transaction
and keep the transaction around to be picked up by the connection that will
eventually commit the XA transaction.

In case of server restart, we have to also recover the MDL locks for any
table involved in the XA transaction.


Generated at Thu Feb 08 09:29:07 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.