[MDEV-29243] Assertion `is_last_prefix <= 0' failed at opt_range.cc:15436 Created: 2022-08-04  Updated: 2023-11-13  Resolved: 2022-08-04

Status: Closed
Project: MariaDB Server
Component/s: Data Manipulation - Insert
Affects Version/s: 10.8.3
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Zuming Jiang Assignee: Oleg Smirnov
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-15656 Assertion `is_last_prefix <= 0' faile... 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

Note: must in READ COMMITTED isolation level

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

conn_0> SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

conn_1> SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

conn_1> START TRANSACTION;

conn_0> START TRANSACTION;

conn_1> delete from t_swbayb;

conn_0> insert into t_swbayb (wkey, pkey) values (88, 74000);

conn_1> insert into t_8fjoxb (wkey, pkey, c_yecif) values
(110, 115000, case when exists (
select
ref_0.wkey as c14
from
t_swbayb as ref_0
where (ref_0.pkey > (
select distinct
ref_1.wkey as c0
from
t_swbayb as ref_1
))) then 'vxg_w' else null end
); --- This INSERT is blocked

conn_0> insert into t_swbayb (wkey, pkey, c_ywdp4d) values (90, 83000, 'vyenkd');

conn_0> COMMIT; --- this COMMIT make the above INSERT in conn_1 crash the MariaDB server

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:07:00 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.