[MDEV-29233] Assertion `lock_table_has(trx, index->table, LOCK_IX)' failed at lock0lock.cc:4972 Created: 2022-08-03  Updated: 2023-09-04  Resolved: 2022-08-03

Status: Closed
Project: MariaDB Server
Component/s: Locking
Affects Version/s: 10.8.3
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Zuming Jiang Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: crash
Environment:

Ubuntu 20.04


Attachments: Text File bug_report.txt     File mysql_bk.sql    
Issue Links:
Duplicate
is duplicated by MDEV-29118 Assertion `lock_table_has(trx, index-... Closed

 Description   

I used my fuzzing tool to test MariaDB and found a transaction-related bug that make the crashes.

Mariadb installation
1) cd mariadb-10.8.3
2) mkdir build; cd build
3) cmake .. -DCMAKE_BUILD_TYPE=Debug -DWITH_ASAN=ON
4) make -j12 && sudo make install

Setup the environment
1) export ASAN_OPTIONS=detect_leaks=0
2) /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql &
3) /usr/local/mysql/bin/mysql -uroot -Dtestdb < mysql_bk.sql (attached) # set up the database

Reproduce bug

/usr/local/mysql/bin/mysql -uroot -Dtestdb # set up connection conn_0
/usr/local/mysql/bin/mysql -uroot -Dtestdb # set up connection conn_1
/usr/local/mysql/bin/mysql -uroot -Dtestdb # set up connection conn_2

conn_1> START TRANSACTION;

conn_2> START TRANSACTION;

conn_0> START TRANSACTION;

conn_1> update t_wmmbvd set wkey = 64;

conn_2> insert into t_gj1wgb (wkey, pkey, c_a7cvid) values
(109, 121000, case when 15 between 34 and 36 then case when exists (
select distinct
ref_0.pkey as c8
from
t_wmmbvd as ref_0
) then '0ulyqb' else 'gog9pb' end
else 'ucbsmc' end
),
(109, 127000, null);

conn_0> delete from t_gj1wgb; --- This Delete is blocked

conn_1> insert into t_wmmbvd (wkey, pkey, c_wnzys, c_gmrl1c, c_rajdu) values
(67, 102000, 'qgziz', 64.93, null),
(67, 104000, case when null in (
select
ref_0.pkey as c0
from
t_gj1wgb as ref_0
) then null else 'nmivpc' end
, 74.22, 'ehl4ac'); --- This INSERT is blocked

conn_2> COMMIT; --- This COMMIT will unblock the above DELETE (in conn_0)

conn_0> update t_wmmbvd set wkey = 42; --- this UPDATE should be putted in conn_0 as soon as possible after the above COMMIT (in conn_2) is executed, and it will make the above INSERT (in conn_1) crash the maridb server

conn_0> COMMIT;

conn_1> COMMIT;

I have simplified the content of the test case, and I hope this report can help you reproduce and fix the bug. In addition, I attached the failure report (which has its stack trace).


Generated at Thu Feb 08 10:06:56 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.