[MDEV-28791] Assertion `!mysql_bin_log.is_open() || thd.is_current_stmt_binlog_format_row()' failed in Delayed_insert::handle_inserts Created: 2022-06-10  Updated: 2023-12-19

Status: Open
Project: MariaDB Server
Component/s: Binary Protocol, Data Manipulation - Insert
Affects Version/s: 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Andrei Elkin
Resolution: Unresolved Votes: 0
Labels: regression, upstream-5.5, upstream-5.6


 Description   

# Keep repeating/looping till it crashes (~2)
# mysqld options required for replay: --log-bin 
DROP DATABASE test;
CREATE DATABASE test;
USE test;
SET GLOBAL binlog_format=1;
SET SESSION default_storage_engine='MEMORY';
SET sql_log_bin=0;
CREATE TABLE t (a INT KEY,b INT);
INSERT DELAYED INTO t VALUES (1,0),(1,0),(1,0);
SET sql_log_bin=1;
SET GLOBAL binlog_format=MIXED;
INSERT DELAYED INTO t VALUES (1,0),(1,0),(1,0);

Leads to:

10.10.0 081a284712bb661349e2e3802077b12211cede3e (Debug)

mysqld: /test/10.10_dbg/sql/sql_insert.cc:3558: bool Delayed_insert::handle_inserts(): Assertion `!mysql_bin_log.is_open() || thd.is_current_stmt_binlog_format_row()' failed.

10.10.0 081a284712bb661349e2e3802077b12211cede3e (Debug)

Core was generated by `/test/MD310522-mariadb-10.10.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x14db78b63700 (LWP 133518))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000014db91dd0859 in __GI_abort () at abort.c:79
#2  0x000014db91dd0729 in __assert_fail_base (fmt=0x14db91f66588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x560bb7388678 "!mysql_bin_log.is_open() || thd.is_current_stmt_binlog_format_row()", file=0x560bb7387fe0 "/test/10.10_dbg/sql/sql_insert.cc", line=3558, function=<optimized out>) at assert.c:92
#3  0x000014db91de1fd6 in __GI___assert_fail (assertion=assertion@entry=0x560bb7388678 "!mysql_bin_log.is_open() || thd.is_current_stmt_binlog_format_row()", file=file@entry=0x560bb7387fe0 "/test/10.10_dbg/sql/sql_insert.cc", line=line@entry=3558, function=function@entry=0x560bb73886c0 "bool Delayed_insert::handle_inserts()") at assert.c:101
#4  0x0000560bb675e568 in Delayed_insert::handle_inserts (this=this@entry=0x14db24058118) at /test/10.10_dbg/sql/log.h:324
#5  0x0000560bb675ff28 in handle_delayed_insert (arg=0x14db24058118) at /test/10.10_dbg/sql/sql_insert.cc:3351
#6  0x000014db922e1609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#7  0x000014db91ecd133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.4.26 (dbg), 10.5.17 (dbg), 10.6.9 (dbg), 10.7.5 (dbg), 10.8.4 (dbg), 10.9.2 (dbg), 10.10.0 (dbg)
MySQL: 5.5.62 (dbg), 5.6.51 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.3.36 (dbg), 10.3.36 (opt), 10.4.26 (opt), 10.5.17 (opt), 10.6.9 (opt), 10.7.5 (opt), 10.8.4 (opt), 10.9.2 (opt), 10.10.0 (opt)
MySQL: 5.5.62 (opt), 5.6.51 (opt), 5.7.38 (dbg), 5.7.38 (opt), 8.0.29 (dbg), 8.0.29 (opt)



 Comments   
Comment by Roel Van de Paar [ 2022-06-10 ]

All asserts/stacks seen across versions:

!(mysql_bin_log.is_open() && !thd.is_current_stmt_binlog_format_row())|SIGABRT|Delayed_insert::handle_inserts|handle_delayed_insert|pfs_spawn_thread|start_thread
!(mysql_bin_log.is_open() && !thd.is_current_stmt_binlog_format_row())|SIGABRT|Delayed_insert::handle_inserts|handle_delayed_insert|start_thread|clone
!mysql_bin_log.is_open() || thd.is_current_stmt_binlog_format_row()|SIGABRT|Delayed_insert::handle_inserts|handle_delayed_insert|start_thread|clone

Comment by Ramesh Sivaraman [ 2023-12-19 ]

Reduced test case

source include/have_log_bin.inc;
 
CREATE TABLE t(id int key)engine=MEMORY;
SET @@GLOBAL.binlog_format=STATEMENT;
SET SQL_LOG_BIN=0;
INSERT DELAYED INTO t VALUES(0);
SET @@GLOBAL.binlog_format=ROW;
SET SQL_LOG_BIN=1;
INSERT DELAYED INTO t VALUES(1);

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