Bug #86485 InnoDB: tried to purge non-delete-marked record
Submitted: 27 May 2017 11:15
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:5.7.17, 8.0.1 OS:Any
Assigned to: CPU Architecture:Any

[27 May 2017 11:15] Shane Bester
Description:
affects debug/release builds of 5.7, 8.0.  
Debug build asserts.  Release build prints out:

InnoDB: tried to purge non-delete-marked record in index `c` of table 
InnoDB: tried to purge non-delete-marked record in index `c` of table 

Version: '5.7.19-debug' (Built on 2017/05/25)
[ERROR] InnoDB: tried to purge non-delete-marked record in index `c` of
InnoDB: Assertion failure in thread 8344 in file row0purge.cc line 499
InnoDB: Failing assertion: 0
 mysqld-debug.exe!my_sigabrt_handler()[my_thr_init.c:449]
 ucrtbased.dll!raise()
 ucrtbased.dll!abort()
 mysqld-debug.exe!ut_dbg_assertion_failed()[ut0dbg.cc:68]
 mysqld-debug.exe!row_purge_remove_sec_if_poss_leaf()[row0purge.cc:499]
 mysqld-debug.exe!row_purge_remove_sec_if_poss()[row0purge.cc:588]
 mysqld-debug.exe!row_purge_del_mark()[row0purge.cc:659]
 mysqld-debug.exe!row_purge_record_func()[row0purge.cc:990]
 mysqld-debug.exe!row_purge()[row0purge.cc:1046]
 mysqld-debug.exe!row_purge_step()[row0purge.cc:1127]
 mysqld-debug.exe!que_thr_step()[que0que.cc:1056]
 mysqld-debug.exe!que_run_threads_low()[que0que.cc:1118]
 mysqld-debug.exe!que_run_threads()[que0que.cc:1160]
 mysqld-debug.exe!srv_task_execute()[srv0srv.cc:2464]
 mysqld-debug.exe!srv_worker_thread()[srv0srv.cc:2512]

How to repeat:
set sql_mode="";
drop table if exists t;
create table t (
  `a` int,
  `b` int not null,
  `c` char(2) generated always as ('aa') virtual,
  unique key(`b`),
  unique key(`c`(1))
) engine=innodb default charset=utf8 row_format=compact;

drop procedure if exists p;
delimiter $
create procedure p()
begin
  declare continue handler for sqlexception begin end;
  repeat
    if rand()>0.5 then insert into t(a,b) values(floor(rand()*10),floor(rand()*10)); end if;
    if rand()>0.5 then delete from t where a<floor(rand()*10); end if;
    if rand()>0.5 then update t set b=concat(a,a); end if;
    if rand()>0.5 then replace into t(a,b) values(floor(rand()*10),floor(rand()*10)); end if;
  until 1=2 end repeat;
end $
delimiter ;

call p();
[30 Jun 2021 16:49] Marcelo Altmann
This has already been fixed on 8.0 by https://github.com/percona/percona-server/commit/ef4a3ee7329afe4dedd8aeee9274fb41fce8aafd
[30 Jun 2021 16:50] Marcelo Altmann
Cherry-picked 8.0 patch and applied it on top of 5.7.34

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: 86485.patch (application/octet-stream, text), 3.04 KiB.