[MDEV-24336] replica in crash loop on mariadb 10.5.7 Created: 2020-12-02  Updated: 2020-12-04  Resolved: 2020-12-04

Status: Closed
Project: MariaDB Server
Component/s: Replication
Affects Version/s: 10.5.7
Fix Version/s: N/A

Type: Bug Priority: Blocker
Reporter: Lei Zeng Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: regression
Environment:

amazon RDS mariadb 10.5.7


Issue Links:
Relates
relates to MDEV-14903 Slave applier segfaults after reconne... Open

 Description   

After setting up replication on mariadb 10.5.7, run the following SQL statements on the source database (master) will lead the replica (slave) into a crash loop. The source database works fine, but on the replica, whenever the SQL thread starts to apply the binlog, it will crash the instance. The binlog format is MIXED.

The factors involved:

  • 2 tables with FK relationship
  • 1 trigger on the child table

CREATE TABLE `parent` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tax` decimal(11,0) DEFAULT 0,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB ;
 
create table child ( 
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_parent` int(11) DEFAULT NULL,
  `name` text DEFAULT NULL,
  `age` float(12,2) DEFAULT NULL,
   PRIMARY KEY (`id`),
  CONSTRAINT `fk_1` FOREIGN KEY (`id_parent`) REFERENCES `parent` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
 
DELIMITER $$
CREATE TRIGGER insert_trg 
    AFTER INSERT ON child
    FOR EACH ROW 
begin
if(new.name='Bob')
then
 update parent set tax=tax+new.age where id = new.id_parent;
end if;
 END$$
DELIMITER ;
 
insert into parent (tax) values (10.1);
insert into  `child` (`id_parent`, `name`, `age`) values ('1', 'Bob', 9);

201202  7:00:00 [ERROR] mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
 
To report this bug, see https://mariadb.com/kb/en/reporting-bugs
 
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed, 
something is definitely wrong and this may fail.
 
Server version: 10.5.7-MariaDB
key_buffer_size=16777216
read_buffer_size=262144
max_used_connections=1
max_threads=156
thread_count=4
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 379517 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
 
Thread pointer: 0x2addcc050e98
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0x2add348e1e78 thread_stack 0x40000
mysys/stacktrace.c:213(my_print_stacktrace)[0x564714a975de]
sql/signal_handler.cc:208(handle_fatal_signal)[0x56471440d345]
sigaction.c:0(__restore_rt)[0x2add35923100]
mysys/my_malloc.c:196(my_free)[0x564714a939ac]
sql/rpl_rli.cc:2364(rpl_group_info::clear_tables_to_lock())[0x5647142fa546]
sql/rpl_rli.cc:2318(rpl_group_info::cleanup_context(THD*, bool))[0x5647142fa661]
sql/log_event_server.cc:5787(Rows_log_event::do_apply_event(rpl_group_info*))[0x56471450f509]
sql/log_event.h:1499(Log_event::apply_event(rpl_group_info*))[0x5647141743dc]
sql/slave.cc:4489(exec_relay_log_event)[0x5647141765fe]
perfschema/pfs.cc:2204(pfs_spawn_thread)[0x56471471480c]
pthread_create.c:0(start_thread)[0x2add3591bdc5]
??:0(__clone)[0x2add35c26c9d]
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x2addcc0ae02b): INSERT INTO `child` (`id_parent`, `name`, `age`) VALUES ('1', 'Bob', 9)
 
Connection ID (thread ID): 5
Status: NOT_KILLED



 Comments   
Comment by Alice Sherepa [ 2020-12-03 ]

Could you please add your .cnf files from master and slave.
I tried with all defaults and could not reproduce the issue. (10.5.7->10.5.7)

MariaDB [test]> show relaylog events in 'p-relay-bin.000002';
+--------------------+------+-------------------+-----------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Log_name           | Pos  | Event_type        | Server_id | End_log_pos | Info                                                                                                                                                                                                                                                                                                                            |
+--------------------+------+-------------------+-----------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| p-relay-bin.000002 |    4 | Format_desc       |         2 |         256 | Server ver: 10.5.7-MariaDB, Binlog ver: 4                                                                                                                                                                                                                                                                                       |
| p-relay-bin.000002 |  256 | Rotate            |         3 |           0 | p-bin.000001;pos=4                                                                                                                                                                                                                                                                                                              |
| p-relay-bin.000002 |  299 | Format_desc       |         3 |         256 | Server ver: 10.5.7-MariaDB-log, Binlog ver: 4                                                                                                                                                                                                                                                                                   |
| p-relay-bin.000002 |  551 | Gtid_list         |         3 |         285 | []                                                                                                                                                                                                                                                                                                                              |
| p-relay-bin.000002 |  580 | Binlog_checkpoint |         3 |         324 | p-bin.000001                                                                                                                                                                                                                                                                                                                    |
| p-relay-bin.000002 |  619 | Gtid              |         3 |         366 | GTID 0-3-1                                                                                                                                                                                                                                                                                                                      |
| p-relay-bin.000002 |  661 | Query             |         3 |         471 | use `test`; SET PASSWORD FOR 'root'@'localhost'=''                                                                                                                                                                                                                                                                              |
| p-relay-bin.000002 |  766 | Gtid              |         3 |         513 | GTID 0-3-2                                                                                                                                                                                                                                                                                                                      |
| p-relay-bin.000002 |  808 | Query             |         3 |         646 | use `test`; GRANT REPLICATION SLAVE ON *.* TO root@'localhost'                                                                                                                                                                                                                                                                  |
| p-relay-bin.000002 |  941 | Gtid              |         3 |         688 | GTID 0-3-3                                                                                                                                                                                                                                                                                                                      |
| p-relay-bin.000002 |  983 | Query             |         3 |         778 | use `test`; create table t1 (i int)                                                                                                                                                                                                                                                                                             |
| p-relay-bin.000002 | 1073 | Gtid              |         3 |         820 | GTID 0-3-4                                                                                                                                                                                                                                                                                                                      |
| p-relay-bin.000002 | 1115 | Query             |         3 |        1020 | use `test`; CREATE TABLE `parent` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tax` decimal(11,0) DEFAULT 0,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB                                                                                                                                                                               |
| p-relay-bin.000002 | 1315 | Gtid              |         3 |        1062 | GTID 0-3-5                                                                                                                                                                                                                                                                                                                      |
| p-relay-bin.000002 | 1357 | Query             |         3 |        1436 | use `test`; create table child ( 
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_parent` int(11) DEFAULT NULL,
  `name` text DEFAULT NULL,
  `age` float(12,2) DEFAULT NULL,
   PRIMARY KEY (`id`),
  CONSTRAINT `fk_1` FOREIGN KEY (`id_parent`) REFERENCES `parent` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB |
| p-relay-bin.000002 | 1731 | Gtid              |         3 |        1478 | GTID 0-3-6                                                                                                                                                                                                                                                                                                                      |
| p-relay-bin.000002 | 1773 | Query             |         3 |        1766 | use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER insert_trg 
    AFTER INSERT ON child
    FOR EACH ROW 
begin
if(new.name='Bob')
then
 update parent set tax=tax+new.age where id = new.id_parent;
end if;
 END                                                                                                           |
| p-relay-bin.000002 | 2061 | Gtid              |         3 |        1808 | BEGIN GTID 0-3-7                                                                                                                                                                                                                                                                                                                |
| p-relay-bin.000002 | 2103 | Intvar            |         3 |        1840 | INSERT_ID=1                                                                                                                                                                                                                                                                                                                     |
| p-relay-bin.000002 | 2135 | Query             |         3 |        1945 | use `test`; insert into parent (tax) values (10.1)                                                                                                                                                                                                                                                                              |
| p-relay-bin.000002 | 2240 | Xid               |         3 |        1976 | COMMIT /* xid=22 */                                                                                                                                                                                                                                                                                                             |
| p-relay-bin.000002 | 2271 | Gtid              |         3 |        2018 | BEGIN GTID 0-3-8                                                                                                                                                                                                                                                                                                                |
| p-relay-bin.000002 | 2313 | Table_map         |         3 |        2166 | table_id: 23 (test.child)                                                                                                                                                                                                                                                                                                       |
| p-relay-bin.000002 | 2366 | Table_map         |         3 |        2218 | table_id: 19 (test.parent)                                                                                                                                                                                                                                                                                                      |
| p-relay-bin.000002 | 2418 | Table_map         |         3 |        2271 | table_id: 23 (test.child)                                                                                                                                                                                                                                                                                                       |
| p-relay-bin.000002 | 2471 | Write_rows_v1     |         3 |        2322 | table_id: 23                                                                                                                                                                                                                                                                                                                    |
| p-relay-bin.000002 | 2522 | Update_rows_v1    |         3 |        2376 | table_id: 19 flags: STMT_END_F                                                                                                                                                                                                                                                                                                  |
| p-relay-bin.000002 | 2576 | Xid               |         3 |        2407 | COMMIT /* xid=23 */                                                                                                                                                                                                                                                                                                             |
+--------------------+------+-------------------+-----------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
28 rows in set (0.000 sec)
 
MariaDB [test]> select * from parent;
+----+------+
| id | tax  |
+----+------+
|  1 |   19 |
+----+------+
1 row in set (0.000 sec)
 
MariaDB [test]> select version();
+----------------+
| version()      |
+----------------+
| 10.5.7-MariaDB |
+----------------+
1 row in set (0.000 sec)

Comment by Lei Zeng [ 2020-12-03 ]

I am sorry that there could be mistake at my side. It is false alarm and please feel free to resolve this. Thanks a lot.

Comment by Alice Sherepa [ 2020-12-04 ]

I am closing the bug, but please write back in case the problem will appear again

Generated at Thu Feb 08 09:29:13 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.