MDEV-27640 trx_has_lock_x() gives wrong result if the table has pending table lock

trx_has_lock_x() fails to find whether the trx has X-lock on the table
when other transactions are waiting for an X or S lock on the table.
parent fcbd3989
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2019, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2019, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2021, MariaDB Corporation. Copyright (c) 2017, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -1979,7 +1979,7 @@ static bool trx_has_lock_x(const trx_t &trx, dict_table_t& table) ...@@ -1979,7 +1979,7 @@ static bool trx_has_lock_x(const trx_t &trx, dict_table_t& table)
/* This thread is executing trx. No other thread can modify our table locks /* This thread is executing trx. No other thread can modify our table locks
(only record locks might be created, in an implicit-to-explicit conversion). (only record locks might be created, in an implicit-to-explicit conversion).
Hence, no mutex is needed here. */ Hence, no mutex is needed here. */
if (n == 1) if (n)
for (const lock_t *lock : trx.lock.table_locks) for (const lock_t *lock : trx.lock.table_locks)
if (lock && lock->type_mode == (LOCK_X | LOCK_TABLE)) if (lock && lock->type_mode == (LOCK_X | LOCK_TABLE))
return true; return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment