[MDEV-9323] Triggers cause server crash Created: 2015-12-24  Updated: 2016-03-30  Resolved: 2016-03-30

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.1.10, 10.0.23-galera
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Cole Busby Assignee: Unassigned
Resolution: Incomplete Votes: 1
Labels: need_feedback
Environment:

ubuntu 14.04.3 LTS "Trusty"
ubuntu 15.10 "Wiley"
installed/updated from apt-get



 Description   

When a table has the following, the galera cluster crashes.

BEFORE INSERT trigger
BEFORE UPDATE trigger

An Update statement within an event can cause the fail condition.
An event which calls a procedure can cause the fail condition.

Our reproduction steps were:

apt-get upgrade from mariadb-server-10.1.9 to mariadb-server-10.1.10
create database
Create table
add SMALLINT flag field
create BEFORE INSERT trigger set flag=1;
create BEFORE UPDATE trigger set flag=1;
insert row (completed)
insert row (fail, primary server crashes)

Restart service
attempt to update/insert
crash

PRODUCTION OCCURENCE (original issue which lead to try reproducing):
Call procedure
UPDATE statement in procedure crashed server.
copy update statement, relaunch server, login run statement
crash



 Comments   
Comment by Elena Stepanova [ 2015-12-26 ]

Could you please paste the stack trace, or better attach the error log from the crashing server?

Please also provide your cnf files.

Comment by Todd Stoffel [ 2016-01-06 ]

160105 19:44:55 [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 http://kb.askmonty.org/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.1.10-MariaDB-1~wily-log
key_buffer_size=134217728
read_buffer_size=8388608
max_used_connections=9
max_threads=72
thread_count=23
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 1901994 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x0x7f8d039fc008
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 = 0x7f8f61450d88 thread_stack 0x48000
/usr/sbin/mysqld(my_print_stacktrace+0x2e)[0x557cc27e076e]
/usr/sbin/mysqld(handle_fatal_signal+0x34d)[0x557cc2336fed]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x10d10)[0x7f90bb57ed10]
/usr/sbin/mysqld(_ZN10Item_field35switch_to_nullable_fields_processorEPh+0x1b)[0x557cc234472b]
/usr/sbin/mysqld(_Z33switch_to_nullable_trigger_fieldsR4ListI4ItemEP5TABLE+0x58)[0x557cc216e888]
/usr/sbin/mysqld(_ZN12multi_update7prepareER4ListI4ItemEP18st_select_lex_unit+0x632)[0x557cc22497e2]
/usr/sbin/mysqld(_ZN4JOIN7prepareEPPP4ItemP10TABLE_LISTjS1_jP8st_orderbS7_S1_S7_P13st_select_lexP18st_select_lex_unit+0xe11)[0x557cc21f7d31]
/usr/sbin/mysqld(_Z12mysql_selectP3THDPPP4ItemP10TABLE_LISTjR4ListIS1_ES2_jP8st_orderSB_S2_SB_yP13select_resultP18st_select_lex_unitP13st_select_lex+0x887)[0x557cc22050f7]
/usr/sbin/mysqld(_Z18mysql_multi_updateP3THDP10TABLE_LISTP4ListI4ItemES6_PS4_y15enum_duplicatesbP18st_select_lex_unitP13st_select_lexPP12multi_update+0xe5)[0x557cc224c895]
/usr/sbin/mysqld(_Z21mysql_execute_commandP3THD+0x2fa6)[0x557cc21ad576]
/usr/sbin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x20e)[0x557cc21b367e]
/usr/sbin/mysqld(+0x40ded9)[0x557cc21b3ed9]
/usr/sbin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x1c2b)[0x557cc21b61bb]
/usr/sbin/mysqld(_Z10do_commandP3THD+0x16d)[0x557cc21b6fdd]
/usr/sbin/mysqld(_Z24do_handle_one_connectionP3THD+0x182)[0x557cc227edf2]
/usr/sbin/mysqld(handle_one_connection+0x40)[0x557cc227efb0]
/usr/sbin/mysqld(+0x6ffb71)[0x557cc24a5b71]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76aa)[0x7f90bb5756aa]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f90bac20eed]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Optimizer switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on

The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.

Comment by Elena Stepanova [ 2016-01-07 ]

Thanks.
What about the cnf files?

Comment by Todd Stoffel [ 2016-01-07 ]

[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock

[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
open_files_limit = 16364
lc_messages_dir = /usr/share/mysql
lc_messages = en_US
skip-external-locking
connect_timeout = 30
max_connections = 70
max-connect-errors = 10000
max_allowed_packet = 16M
interactive_timeout = 180
wait_timeout = 180
event_scheduler = OFF
performance_schema = ON
feedback = ON
log_bin_trust_function_creators = 1

table_definition_cache = 1000
thread_cache_size = 128
sort_buffer_size = 16M
bulk_insert_buffer_size = 16M
tmp_table_size = 1G
max_heap_table_size = 1G
myisam-recover-options = BACKUP
key_buffer_size = 128M
myisam_sort_buffer_size = 32M
concurrent_insert = 2
read_buffer_size = 8M
read_rnd_buffer_size = 1M
query_cache_size = 0
query_cache_type = 0
join_buffer_space_limit = 1024M
optimizer_switch='optimize_join_buffer_size=on,mrr=on,mrr_sort_keys=on'

log_warnings = 1
log_error = /var/log/mysql/mariadb-error.log
long_query_time = 10
slow_query_log = ON
slow_query_log_file = /var/log/mysql/mariadb-slow.log
log_queries_not_using_indexes = OFF

log-bin = /var/log/mysql/mariadb-bin
expire-logs-days = 1
sync-binlog = 0
max_binlog_size = 100M

server_id = 1

default_storage_engine = InnoDB
innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_io_capacity = 300
innodb_io_capacity_max = 3000
innodb_log_file_size = 256M
innodb_buffer_pool_size = 8G
innodb_buffer_pool_instances = 8
innodb_log_buffer_size = 32M
innodb_adaptive_hash_index = 0
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 0
innodb_flush_method = O_DIRECT
innodb_buffer_pool_dump_at_shutdown = 1
innodb_buffer_pool_load_at_startup = 1
innodb_doublewrite = 1

[galera]
wsrep_on=ON
bind_address=0.0.0.0
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_provider_options="gcache.size = 5G"
wsrep_cluster_name="galera_cluster"
wsrep_cluster_address="gcomm://172.31.36.74,172.31.32.41?pc.wait_prim=no"
#wsrep_cluster_address="gcomm://"
binlog_format=ROW
innodb_autoinc_lock_mode=2
wsrep_auto_increment_control = 0
wsrep_retry_autocommit=4
wsrep_slave_threads=16
wsrep_node_address="172.31.44.195"
wsrep_node_name="galera1"
wsrep_max_ws_size=2147483648
wsrep_sst_auth="REMOVED:REMOVED"
wsrep_sst_method=xtrabackup-v2

[mysqldump]
quick
quote-names
max_allowed_packet = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer = 16M

!includedir /etc/mysql/conf.d/

Comment by Elena Stepanova [ 2016-01-11 ]

Does not crash for me:

MariaDB [test]> show status like 'wsrep_cluster%';
+--------------------------+--------------------------------------+
| Variable_name            | Value                                |
+--------------------------+--------------------------------------+
| wsrep_cluster_conf_id    | 2                                    |
| wsrep_cluster_size       | 2                                    |
| wsrep_cluster_state_uuid | 8cabbc97-b85a-11e5-a526-16b7f58db457 |
| wsrep_cluster_status     | Primary                              |
+--------------------------+--------------------------------------+
4 rows in set (0.01 sec)
 
MariaDB [test]> select @@version;
+---------------------------+
| @@version                 |
+---------------------------+
| 10.1.10-MariaDB-debug-log |
+---------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> create database db1;
Query OK, 1 row affected (0.18 sec)
 
MariaDB [(none)]> use db1;
Database changed
MariaDB [db1]> create table t1 (pk int auto_increment primary key, flag smallint);
Query OK, 0 rows affected (1.10 sec)
 
MariaDB [db1]> create trigger tr1 before insert on t1 for each row set new.flag=1;
Query OK, 0 rows affected (0.32 sec)
 
MariaDB [db1]> create trigger tr2 before update on t1 for each row set new.flag=1;
Query OK, 0 rows affected (0.29 sec)
 
MariaDB [db1]> insert into t1 (flag) values (2);
Query OK, 1 row affected (0.00 sec)
 
MariaDB [db1]> insert into t1 (flag) values (3);
Query OK, 1 row affected (0.00 sec)
 
MariaDB [db1]> insert into t1 () values ();
Query OK, 1 row affected (0.00 sec)
 
MariaDB [db1]> insert into t1 values (5,6);
Query OK, 1 row affected (0.00 sec)
 
MariaDB [db1]> update t1 set flag = 10;
Query OK, 0 rows affected (0.01 sec)
Rows matched: 4  Changed: 0  Warnings: 0

Could you please provide the exact definition of the table in use show create table, triggers, and example of a query that causes the crash?

Thanks.

Comment by Allan Sun [ 2016-01-29 ]

I am experiencing exactly the same error.

Apparently when using INSERT in a trigger the server would crash.

CREATE TABLE `agent_consignment` (
  `id` bigint(16) unsigned NOT NULL,
  `company_id` int(10) unsigned NOT NULL,
  `client_id` int(10) unsigned NOT NULL,
  `delivery_agent_id` int(10) unsigned NOT NULL,
  `delivery_agent_account` int(10) unsigned NOT NULL,
  `delivery_service_name` varchar(50) DEFAULT NULL,
  `delivery_reference` varchar(50) DEFAULT NULL,
  `sales_reference` varchar(50) DEFAULT NULL,
  `number_of_package` tinyint(4) NOT NULL DEFAULT '1',
  `contact` varchar(50) DEFAULT NULL,
  `address_line1` varchar(100) DEFAULT NULL,
  `address_line2` varchar(100) DEFAULT NULL,
  `address_line3` varchar(100) DEFAULT NULL,
  `city` varchar(50) DEFAULT NULL,
  `county` varchar(50) DEFAULT NULL,
  `post_code` varchar(50) DEFAULT NULL,
  `country_iso` char(2) NOT NULL,
  `email` varchar(100) DEFAULT NULL,
  `weight` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
  `fee` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
  `cost` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `delivery_time` timestamp NULL DEFAULT NULL,
  `status` enum('PREPARING','FINISHED','DELETED') NOT NULL DEFAULT 'PREPARING',
  PRIMARY KEY (`id`),
  KEY `fk_agent_consignment_client1_idx` (`client_id`),
  KEY `fk_agent_consignment_delivery_agent1_idx` (`delivery_agent_id`),
  KEY `idx_company_id_client_id_create_time` (`create_time`,`company_id`,`client_id`),
  KEY `idx_create_time` (`create_time`),
  KEY `fk_agent_consignment_country1_idx` (`country_iso`),
  KEY `agent_consignment_company_id_fk_1` (`company_id`),
  CONSTRAINT `agent_consignment_company_id_fk_1` FOREIGN KEY (`company_id`) REFERENCES `company` (`id`),
  CONSTRAINT `fk_agent_consignment_client1` FOREIGN KEY (`client_id`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_agent_consignment_country1` FOREIGN KEY (`country_iso`) REFERENCES `country` (`iso`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_agent_consignment_delivery_agent1` FOREIGN KEY (`delivery_agent_id`) REFERENCES `delivery_agent` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
CREATE TABLE `client_statement` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `company_id` int(10) unsigned NOT NULL,
  `client_id` int(10) unsigned NOT NULL,
  `record_id` bigint(16) unsigned DEFAULT NULL,
  `company_user_id` int(10) unsigned DEFAULT NULL,
  `amount` decimal(10,2) NOT NULL DEFAULT '0.00',
  `balance` decimal(10,2) NOT NULL DEFAULT '0.00',
  `note` tinytext,
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` enum('INACTIVE','ACTIVE') NOT NULL DEFAULT 'ACTIVE',
  `type` enum('CONSIGNMENT_FEE_LOCAL','CONSIGNMENT_FEE_DIRECT','CONSIGNMENT_FEE_RETURN','REFUND','MEMBERSHIP_FEE','ADJUSTMENT','TOP_UP','WAREHOUSE_DISPATCH_FEE','CLIENT_DISPATCH_FEE','CLIENT_TRANSFER','SERVICE_CHARGE','CONSIGNMENT_FEE_BATCH','CONSIGNMENT_FEE_AGENT','CLIENT_DISPATCH_FEE_MANUAL','COMPENSATION','STORAGE_FEE','SHARED_PRODUCT_REVENUE','SHARED_PRODUCT_COST') NOT NULL DEFAULT 'CONSIGNMENT_FEE_LOCAL',
  PRIMARY KEY (`id`),
  KEY `client_statement_client_id_idx` (`client_id`),
  KEY `client_statement_update_time` (`update_time`),
  KEY `client_statement_status_idx` (`status`),
  KEY `client_statement_type_idx` (`type`),
  KEY `client_statement_type_record_id_idx` (`type`,`record_id`),
  KEY `company_id` (`company_id`),
  CONSTRAINT `client_statement_company_id_ibfk_1` FOREIGN KEY (`company_id`) REFERENCES `company` (`id`),
  CONSTRAINT `client_statement_ibfk_1` FOREIGN KEY (`client_id`) REFERENCES `client` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 ;
 
thisTrigger: BEGIN IF ((@TRIGGER_CHECKS = FALSE) OR (@TRIGGER_AFTER_UPDATE_CHECKS = FALSE)) THEN LEAVE thisTrigger;END IF;
 
	CALL log('Client ID',NEW.client_id);
	CALL log('Company ID', NEW.company_id);
	CALL log('Fee',NEW.fee);
	
/*	IF NEW.status <> OLD.status AND NEW.status = 'FINISHED'
	THEN
		INSERT INTO `client_statement` (`type`, client_id, company_id, record_id, amount)
		VALUES ('CONSIGNMENT_FEE_AGENT', NEW.client_id, NEW.company_id, NEW.id, -1 * (NEW.fee));
	END IF;*/
 
	IF NEW.status <> OLD.status AND OLD.status = 'FINISHED'
	THEN
		INSERT INTO `client_statement` (`type`, client_id, company_id, record_id, amount)
		VALUES ('CONSIGNMENT_FEE_AGENT', NEW.client_id, NEW.company_id, NEW.id, +1 * (OLD.fee));
	END IF;
 
END
 
 

Comment by Elena Stepanova [ 2016-02-29 ]

allansun,
Thanks, but for this test case to be useful, we need complete structures – the trigger, the procedure used in the trigger, tables referenced by foreign keys (if foreign keys play a role here), and example of the data and statement that causes the problem.
If possible, please also check whether the problem is reproducible with 10.1.12 – we had a somewhat similar bug MDEV-9535 fixed there (or provide information as above, and we'll check it ourselves).

Comment by Elena Stepanova [ 2016-03-30 ]

Please comment to re-open if you have further information on the issue. Meanwhile, we can only hope that it was fixed along with MDEV-9535.

Generated at Thu Feb 08 07:33:48 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.