[MDEV-33244] Slave: Assertion `marked_for_write_or_computed()' failed in Field_long::store Created: 2024-01-15  Updated: 2024-01-15

Status: Open
Project: MariaDB Server
Component/s: Replication
Affects Version/s: 11.2, 11.3, 11.4
Fix Version/s: 11.2, 11.3

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Andrei Elkin
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-22916 Assertion `share->tmp_table == NO_TMP... Confirmed

 Description   

# Requires a normal m/s replication setup
SET SESSION binlog_format=STATEMENT;
CREATE TEMPORARY TABLE t2 (id INT);
CREATE TABLE t1 (c INT);
CREATE TABLE t (c INT);
CREATE TEMPORARY TABLE t (c INT);
INSERT INTO t SELECT table_rows FROM information_schema.tables LIMIT 1;
SHOW WARNINGS\G  # 1592: Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT
SHUTDOWN;

Leads to:

11.4.0 9bd95e914f3f12d0d9d93e7a1f2c49e6e8841f17 (Debug)

mariadbd: /test/11.4_dbg/sql/field.cc:4465: virtual int Field_long::store(longlong, bool): Assertion `marked_for_write_or_computed()' failed.

11.4.0 9bd95e914f3f12d0d9d93e7a1f2c49e6e8841f17 (Debug)

Core was generated by `/test/MD271223-mariadb-11.4.0-linux-x86_64-dbg/bin/mariadbd --no-defaults --gti'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=22749814892096)
    at ./nptl/pthread_kill.c:44
[Current thread is 1 (Thread 0x14b0daa2a640 (LWP 1092621))]
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=22749814892096) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=22749814892096) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=22749814892096, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x000014b103e42476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x000014b103e287f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x000014b103e2871b in __assert_fail_base (fmt=0x14b103fdd130 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x56018beec730 "marked_for_write_or_computed()", file=0x56018beea983 "/test/11.4_dbg/sql/field.cc", line=4465, function=<optimized out>) at ./assert/assert.c:92
#6  0x000014b103e39e96 in __GI___assert_fail (assertion=0x56018beec730 "marked_for_write_or_computed()", file=0x56018beea983 "/test/11.4_dbg/sql/field.cc", line=4465, function=0x56018beee080 "virtual int Field_long::store(longlong, bool)") at ./assert/assert.c:101
#7  0x000056018b43e9b1 in Field_long::store (this=this@entry=0x14afa401b818, nr=0, unsigned_val=unsigned_val@entry=true) at /test/11.4_dbg/sql/field.cc:4465
#8  0x000056018b2b11d9 in Field_num::save_in_field (this=<optimized out>, to=0x14afa401b818) at /test/11.4_dbg/sql/field.h:2105
#9  0x000056018b2b0be9 in Field::store_field (this=<optimized out>, from=<optimized out>) at /test/11.4_dbg/sql/field.h:924
#10 0x000056018b44e4ba in field_conv_incompatible (to=to@entry=0x14afa401b818, from=from@entry=0x14afa401f840) at /test/11.4_dbg/sql/field_conv.cc:899
#11 0x000056018b44fa17 in field_conv (to=0x14afa401b818, from=0x14afa401f840) at /test/11.4_dbg/sql/field_conv.cc:912
#12 0x000056018b477bee in save_field_in_field (from=<optimized out>, null_value=<optimized out>, to=<optimized out>, no_conversions=<optimized out>) at /test/11.4_dbg/sql/item.cc:6692
#13 0x000056018b477c72 in Item_field::save_in_field (this=<optimized out>, to=<optimized out>, no_conversions=<optimized out>) at /test/11.4_dbg/sql/item.cc:6742
#14 0x000056018b0deb73 in fill_record (thd=thd@entry=0x14afa4000f98, table=table@entry=0x14afa4019898, ptr=0x14afa401b800, ptr@entry=0x14afa401b7f8, values=@0x14afa400ba30: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14afa400bd60, last = 0x14afa400bd60, elements = 1}, <No data fields>}, ignore_errors=ignore_errors@entry=true, use_value=use_value@entry=false) at /test/11.4_dbg/sql/sql_base.cc:9333
#15 0x000056018b0decd3 in fill_record_n_invoke_before_triggers (thd=0x14afa4000f98, table=0x14afa4019898, ptr=0x14afa401b7f8, values=@0x14afa400ba30: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14afa400bd60, last = 0x14afa400bd60, elements = 1}, <No data fields>}, ignore_errors=ignore_errors@entry=true, event=event@entry=TRG_EVENT_INSERT) at /test/11.4_dbg/sql/sql_base.cc:9388
#16 0x000056018b112a89 in select_insert::store_values (this=0x14afa400d9c0, values=@0x14afa400ba30: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14afa400bd60, last = 0x14afa400bd60, elements = 1}, <No data fields>}) at /test/11.4_dbg/sql/sql_insert.cc:4238
#17 0x000056018b11463f in select_insert::send_data (this=0x14afa400d9c0, values=<optimized out>) at /test/11.4_dbg/sql/sql_insert.cc:4172
#18 0x000056018b1d12a6 in select_result_sink::send_data_with_check (sent=<optimized out>, u=<optimized out>, items=@0x14afa400ba30: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14afa400bd60, last = 0x14afa400bd60, elements = 1}, <No data fields>}, this=<optimized out>) at /test/11.4_dbg/sql/sql_class.h:5945
#19 end_send (join=0x14afa400da80, join_tab=0x14afa402d770, end_of_records=<optimized out>) at /test/11.4_dbg/sql/sql_select.cc:24767
#20 0x000056018b19e76e in evaluate_join_record (join=join@entry=0x14afa400da80, join_tab=join_tab@entry=0x14afa402d300, error=error@entry=0) at /test/11.4_dbg/sql/sql_select.cc:23733
#21 0x000056018b1b5e34 in sub_select (join=0x14afa400da80, join_tab=0x14afa402d300, end_of_records=false) at /test/11.4_dbg/sql/sql_select.cc:23500
#22 0x000056018b1ed1bf in do_select (procedure=0x0, join=0x14afa400da80) at /test/11.4_dbg/sql/sql_select.cc:23017
#23 JOIN::exec_inner (this=this@entry=0x14afa400da80) at /test/11.4_dbg/sql/sql_select.cc:4940
#24 0x000056018b1ed754 in JOIN::exec (this=this@entry=0x14afa400da80) at /test/11.4_dbg/sql/sql_select.cc:4726
#25 0x000056018b1eb55f in mysql_select (thd=thd@entry=0x14afa4000f98, tables=0x14afa400bdc0, fields=@0x14afa400ba30: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14afa400bd60, last = 0x14afa400bd60, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=37386131081984, result=0x14afa400d9c0, unit=0x14afa4005410, select_lex=0x14afa400b778) at /test/11.4_dbg/sql/sql_select.cc:5249
#26 0x000056018b1ebd88 in handle_select (thd=thd@entry=0x14afa4000f98, lex=lex@entry=0x14afa4005330, result=result@entry=0x14afa400d9c0, setup_tables_done_option=setup_tables_done_option@entry=35184372088832) at /test/11.4_dbg/sql/sql_select.cc:628
#27 0x000056018b159cc7 in mysql_execute_command (thd=thd@entry=0x14afa4000f98, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/11.4_dbg/sql/sql_parse.cc:4579
#28 0x000056018b15e4bb in mysql_parse (thd=0x14afa4000f98, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14b0daa29690) at /test/11.4_dbg/sql/sql_parse.cc:7748
#29 0x000056018b5df3ce in Query_log_event::do_apply_event (this=0x14b0b006e9d8, rgi=0x14b0b0063bd0, query_arg=0x14b0b006eb33 "INSERT INTO t SELECT table_rows FROM information_schema.tables LIMIT 1", q_len_arg=<optimized out>) at /test/11.4_dbg/sql/sql_class.h:253
#30 0x000056018b5dfc65 in Query_log_event::do_apply_event (this=<optimized out>, rgi=<optimized out>) at /test/11.4_dbg/sql/log_event_server.cc:1500
#31 0x000056018b5d050f in Log_event::apply_event (this=this@entry=0x14b0b006e9d8, rgi=rgi@entry=0x14b0b0063bd0) at /test/11.4_dbg/sql/log_event.cc:3876
#32 0x000056018b08000e in apply_event_and_update_pos_apply (ev=ev@entry=0x14b0b006e9d8, thd=thd@entry=0x14afa4000f98, rgi=rgi@entry=0x14b0b0063bd0, reason=reason@entry=0) at /test/11.4_dbg/sql/slave.cc:3910
#33 0x000056018b08a2dd in apply_event_and_update_pos_for_parallel (ev=ev@entry=0x14b0b006e9d8, thd=thd@entry=0x14afa4000f98, rgi=rgi@entry=0x14b0b0063bd0) at /test/11.4_dbg/sql/slave.cc:4117
#34 0x000056018b360775 in rpt_handle_event (qev=qev@entry=0x14b0b0065b08, rpt=rpt@entry=0x14b0b0028268) at /test/11.4_dbg/sql/rpl_parallel.cc:64
#35 0x000056018b365532 in handle_rpl_parallel_thread (arg=arg@entry=0x14b0b0028268) at /test/11.4_dbg/sql/rpl_parallel.cc:1542
#36 0x000056018b70c73a in pfs_spawn_thread (arg=0x14b0b00396d8) at /test/11.4_dbg/storage/perfschema/pfs.cc:2201
#37 0x000014b103e94ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#38 0x000014b103f26850 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Bug confirmed present in:
MariaDB: 11.2.3 (dbg), 11.3.2 (dbg), 11.4.0 (dbg)

It is the slave that crashes. In versions 10.4 to 11.1 this testcase results in the same stack as seen in MDEV-22916. And, the testcase from that ticket produces no error in 11.1+.



 Comments   
Comment by Roel Van de Paar [ 2024-01-15 ]

Issue readily reproduces in the CLI but not in MTR. Final attempt was:

--source include/have_binlog_format_statement.inc
--source include/master-slave.inc
--source include/have_innodb.inc
 
CREATE TEMPORARY TABLE t2 (id INT) ENGINE=InnoDB;
CREATE TABLE t1 (c INT) ENGINE=InnoDB;
CREATE TABLE t (c INT) ENGINE=InnoDB;
CREATE TEMPORARY TABLE t (c INT) ENGINE=InnoDB;
INSERT INTO t SELECT table_rows FROM information_schema.tables LIMIT 1;
SHUTDOWN;
 
--sync_slave_with_master

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