[MDEV-11249] Server crash when run query Created: 2016-11-08  Updated: 2021-01-18  Resolved: 2021-01-18

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.1.18
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Mr.Hai Assignee: Elena Stepanova
Resolution: Incomplete Votes: 0
Labels: None
Environment:

Ubuntu 14.04


Attachments: Microsoft Word SQL Error.rtf     File dms-structures.sql     HTML File profile.htm    

 Description   

Please hepl us to address this problem.

Thanks



 Comments   
Comment by Mr.Hai [ 2016-11-08 ]

This is profile for the query profile.htm

Comment by Elena Stepanova [ 2016-11-12 ]

From SQL Error.rtf

161108  7:01: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 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.1.18-MariaDB-1~jessie
 key_buffer_size=134217728
 read_buffer_size=2097152
 max_used_connections=96
 max_threads=102
 thread_count=19
 It is possible that mysqld could use up to
 key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 759834 K  bytes of memory
 Hope that's ok; if not, decrease some variables in the equation.
 
 Thread pointer: 0x0x7f51bd9cc008
 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 = 0x7f51c64c61f8 thread_stack 0x48400
 mysqld(my_print_stacktrace+0x2e)[0x7f51f783e2be]
 mysqld(handle_fatal_signal+0x2d5)[0x7f51f737a785]
 /lib/x86_64-linux-gnu/libpthread.so.0(+0xf8d0)[0x7f51f69a48d0]
 mysqld(_ZN4JOIN4execEv+0x11)[0x7f51f724d241]
 mysqld(_ZN18st_select_lex_unit4execEv+0x824)[0x7f51f728b664]
 mysqld(_Z11mysql_unionP3THDP3LEXP13select_resultP18st_select_lex_unitm+0x2d)[0x7f51f728e0cd]
 mysqld(_Z13handle_selectP3THDP3LEXP13select_resultm+0x59)[0x7f51f724a339]
 mysqld(+0x413491)[0x7f51f71e8491]
 mysqld(_Z21mysql_execute_commandP3THD+0x600a)[0x7f51f71f454a]
 mysqld(_ZN13sp_instr_stmt9exec_coreEP3THDPj+0x15)[0x7f51f7477fa5]
 mysqld(_ZN13sp_lex_keeper23reset_lex_and_exec_coreEP3THDPjbP8sp_instr+0x83)[0x7f51f747f193]
 mysqld(_ZN13sp_instr_stmt7executeEP3THDPj+0x21c)[0x7f51f747f75c]
 mysqld(_ZN7sp_head7executeEP3THDb+0x76e)[0x7f51f747b5ee]
 mysqld(_ZN7sp_head17execute_procedureEP3THDP4ListI4ItemE+0x769)[0x7f51f747cdc9]
 mysqld(+0x412fa6)[0x7f51f71e7fa6]
 mysqld(_Z21mysql_execute_commandP3THD+0x42c5)[0x7f51f71f2805]
 mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x285)[0x7f51f71f78b5]
 mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x1c89)[0x7f51f71fa3e9]
 mysqld(_Z10do_commandP3THD+0x16e)[0x7f51f71fab2e]
 mysqld(_Z24do_handle_one_connectionP3THD+0x182)[0x7f51f72c5022]
 mysqld(handle_one_connection+0x40)[0x7f51f72c51e0]
 /lib/x86_64-linux-gnu/libpthread.so.0(+0x80a4)[0x7f51f699d0a4]
 /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f51f4b4762d]
 
 Trying to get some variables.
 Some pointers may be invalid and cause the dump to abort.
 Query (0x7f51c60c1d10): SELECT      1 AS `rank`,      a.`reference`,       fc_remove_sign( a.`reference`) code_ref,      COUNT(a.`lead_id`) AS `leads`,      COUNT(IF(a.`type` = 'OPPORTUNITY', a.`lead_id`, NULL)) AS `opps`,      COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 0, a.`lead_id`, NULL)) AS `x`,      COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 1, a.`lead_id`, NULL)) AS `x1`,      COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 2, a.`lead_id`, NULL)) AS `x2`,      COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 3, a.`lead_id`, NULL)) AS `x3`,      COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 4, a.`lead_id`, NULL)) AS `x4`    FROM (SELECT        `fc_get_reference_name`(IFNULL(fl.`source_type`, vs.`source_type`), vs.`source_reference`) AS `reference`,        vs.`lead_id`,        l.`type`,        c.`ID` AS `contract_id`,        IF(c.`ID` IS NOT NULL, `fc_get_total_months`(l.`created`, c.`date_created`), NULL) AS `total_months`      FROM `v_trial_service_sources` vs        LEFT JOIN `v_field_log_sources` fl          ON vs.`lead_id` = fl.`lead_id`        INNER JOIN `crm_leads` l          ON l.`ID` = vs.`lead_id`        LEFT JOIN `crm_contracts` c          ON l.`ID` = c.`potential_id`          AND c.`total_price_internal` > 0          AND c.`website` = vs.`website`      WHERE vs.`lead_id` IS NOT NULL      AND (fl.`source_type` = 2      OR (fl.`source_type` IS NULL      AND vs.`source_type` = 2))      AND l.`service_id` = IF( NAME_CONST('p_service_id',NULL) IS NULL      OR  NAME_CONST('p_service_id',NULL) = -1, l.`service_id`,  NAME_CONST('p_service_id',NULL))      AND l.`created` BETWEEN  NAME_CONST('_date_created_from',_latin1'2016-11-01' COLLATE 'latin1_swedish_ci') AND  NAME_CONST('_date_created_to',_latin1'2016-11-30' COLLATE 'latin1_swedish_ci')      AND vs.`created` BETWEEN  NAME_CONST('_date_created_from',_latin1'2016-11-01' COLLATE 'latin1_swedish_ci') AND  NAME_CONST('_date_created_to',_latin1'2016-11-30' COLLATE 'latin1_swedish_ci')) a    GROUP BY a.`reference`    HAVING a.`reference` = IFNULL( NAME_CONST('p_source_ref',NULL), a.`reference`)      UNION      SELECT      1 AS `rank`,      a.`reference`,      fc_remove_sign( a.`reference`) code_ref,      COUNT(a.`lead_id`) AS `leads`,      COUNT(IF(a.`type` = 'OPPORTUNITY', a.`lead_id`, NULL)) AS `opps`,      COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 0, a.`lead_id`, NULL)) AS `x`,      COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 1, a.`lead_id`, NULL)) AS `x1`,      COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 2, a.`lead_id`, NULL)) AS `x2`,      COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 3, a.`lead_id`, NULL)) AS `x3`,      COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 4, a.`lead_id`, NULL)) AS `x4`    FROM (SELECT        `fc_get_reference_name`(l.`source_type`, NULL) AS `reference`,        l.`ID` AS `lead_id`,        l.`type`,        c.`ID` AS `contract_id`,        IF(c.`ID` IS NOT NULL, `fc_get_total_months`(l.`created`, c.`date_created`), NULL) AS `total_months`      FROM `crm_leads` l        LEFT JOIN `crm_contracts` c          ON l.`ID` = c.`potential_id`          AND c.`total_price_internal` > 0      WHERE l.`source_type` != 2      AND l.`service_id` = IF( NAME_CONST('p_service_id',NULL) IS NULL      OR  NAME_CONST('p_service_id',NULL) = -1, l.`service_id`,  NAME_CONST('p_service_id',NULL))      AND l.`created` BETWEEN  NAME_CONST('_date_created_from',_latin1'2016-11-01' COLLATE 'latin1_swedish_ci') AND  NAME_CONST('_date_created_to',_latin1'2016-11-30' COLLATE 'latin1_swedish_ci')) a    GROUP BY a.`reference`    HAVING a.`reference` LIKE  IFNULL( NAME_CONST('p_source_ref',NULL), a.`reference`)
 Connection ID (thread ID): 51273
 Status: NOT_KILLED
 
 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=off,mrr_cost_based=off,mrr_sort_keys=off,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=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=off

From profile.htm

id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	PRIMARY	ts	ALL	PRIMARY,lead_id	(NULL)	(NULL)	(NULL)	191993	50.00	Using where; Using temporary; Using filesort
1	PRIMARY	l	eq_ref	PRIMARY	PRIMARY	4	dms.ts.lead_id	1	100.00	Using where
1	PRIMARY	c	ref	potential_id	potential_id	9	dms.ts.lead_id	1	100.00	Using where
1	PRIMARY	tsm1	ref	trial_service_id,meta_key,meta_value	trial_service_id	4	dms.ts.id	3	100.00	Using where
1	PRIMARY	tsm2	ref	trial_service_id,meta_key	trial_service_id	4	dms.ts.id	3	100.00	Using where
1	PRIMARY	<derived6>	ref	key0	key0	5	dms.ts.lead_id	10	100.00	Using where
6	DERIVED	fl	index	TableColumnRow	Idx_row_id	5	(NULL)	27841	100.00	Using where
3	UNION	l	ALL	(NULL)	(NULL)	(NULL)	(NULL)	1031135	100.00	Using where; Using temporary; Using filesort
3	UNION	c	ref	potential_id	potential_id	9	dms.l.id	1	100.00	Using where
(NULL)	UNION RESULT	<union1,3>	ALL	(NULL)	(NULL)	(NULL)	(NULL)	(NULL)	(NULL)	

SELECT      
1 AS `rank`,      
a.`reference`,      
 fc_remove_sign( a.`reference`) code_ref,      
COUNT(a.`lead_id`) AS `leads`,      
COUNT(IF(a.`type` = 'OPPORTUNITY', a.`lead_id`, NULL)) AS `opps`,      
COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 0, a.`lead_id`, NULL)) AS `x`,      
COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 1, a.`lead_id`, NULL)) AS `x1`,      
COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 2, a.`lead_id`, NULL)) AS `x2`,      
COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 3, a.`lead_id`, NULL)) AS `x3`,      
COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 4, a.`lead_id`, NULL)) AS `x4`    FROM (SELECT      
  `fc_get_reference_name`(IFNULL(fl.`source_type`, vs.`source_type`), vs.`source_reference`) AS `reference`,      
  vs.`lead_id`,      
  l.`type`,      
  c.`ID` AS `contract_id`,      
  IF(c.`ID` IS NOT NULL, `fc_get_total_months`(l.`created`, c.`date_created`), NULL) AS `total_months`      
FROM `v_trial_service_sources` vs      
  LEFT JOIN `v_field_log_sources` fl      
    ON vs.`lead_id` = fl.`lead_id`      
  INNER JOIN `crm_leads` l      
    ON l.`ID` = vs.`lead_id`      
  LEFT JOIN `crm_contracts` c      
    ON l.`ID` = c.`potential_id`      
    AND c.`total_price_internal` > 0      
    AND c.`website` = vs.`website`      
WHERE vs.`lead_id` IS NOT NULL      
AND (fl.`source_type` = 2      
OR (fl.`source_type` IS NULL      
AND vs.`source_type` = 2))      
AND l.`service_id` = IF( NAME_CONST('p_service_id',NULL) IS NULL      
OR  NAME_CONST('p_service_id',NULL) = -1, l.`service_id`,  NAME_CONST('p_service_id',NULL))      
AND l.`created` BETWEEN  NAME_CONST('_date_created_from',_latin1'2016-11-01' COLLATE 'latin1_swedish_ci') AND  NAME_CONST('_date_created_to',_latin1'2016-11-30' COLLATE 'latin1_swedish_ci')      
AND vs.`created` BETWEEN  NAME_CONST('_date_created_from',_latin1'2016-11-01' COLLATE 'latin1_swedish_ci') AND  NAME_CONST('_date_created_to',_latin1'2016-11-30' COLLATE 'latin1_swedish_ci')) a    GROUP BY a.`reference`    HAVING a.`reference` = IFNULL( NAME_CONST('p_source_ref',NULL), a.`reference`)      
UNION      
SELECT      
1 AS `rank`,      
a.`reference`,      
fc_remove_sign( a.`reference`) code_ref,      
COUNT(a.`lead_id`) AS `leads`,      
COUNT(IF(a.`type` = 'OPPORTUNITY', a.`lead_id`, NULL)) AS `opps`,      
COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 0, a.`lead_id`, NULL)) AS `x`,      
COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 1, a.`lead_id`, NULL)) AS `x1`,      
COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 2, a.`lead_id`, NULL)) AS `x2`,      
COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 3, a.`lead_id`, NULL)) AS `x3`,      
COUNT(IF(a.`contract_id` IS NOT NULL AND a.`total_months` = 4, a.`lead_id`, NULL)) AS `x4`    FROM (SELECT      
  `fc_get_reference_name`(l.`source_type`, NULL) AS `reference`,      
  l.`ID` AS `lead_id`,      
  l.`type`,      
  c.`ID` AS `contract_id`,      
  IF(c.`ID` IS NOT NULL, `fc_get_total_months`(l.`created`, c.`date_created`), NULL) AS `total_months`      
FROM `crm_leads` l      
  LEFT JOIN `crm_contracts` c      
    ON l.`ID` = c.`potential_id`      
    AND c.`total_price_internal` > 0      
WHERE l.`source_type` != 2      
AND l.`service_id` = IF( NAME_CONST('p_service_id',NULL) IS NULL      
OR  NAME_CONST('p_service_id',NULL) = -1, l.`service_id`,  NAME_CONST('p_service_id',NULL))      
AND l.`created` BETWEEN  NAME_CONST('_date_created_from',_latin1'2016-11-01' COLLATE 'latin1_swedish_ci') AND  NAME_CONST('_date_created_to',_latin1'2016-11-30' COLLATE 'latin1_swedish_ci')) a    GROUP BY a.`reference`    HAVING a.`reference` LIKE  IFNULL( NAME_CONST('p_source_ref',NULL), a.`reference`)

Comment by Elena Stepanova [ 2016-11-12 ]

haind.dkt,

Would you be able to provide the database dump? Full dump would be optimal in order to reproduce the issue, but if you can't do it due to privacy concerns, please dump the structures only, without the table data.
mysqldump --routines <database name> – full dump
mysqldump --routines --no-data <database name> – structures only

Whichever you choose, please upload it to ftp.askmonty.org/private (or attach to the issue if it's small enough and does not contain any confidential data).
Please also attach your cnf file(s).

Thanks.

Comment by Mr.Hai [ 2016-11-14 ]

Dear Mr.Elena,
This is my config

# config/mysql/config-file.cnf
[mysqld] 
default_time_zone='+07:00'
 
[mariadb]
log-bin
server_id=1
log-basename=master1
max_binlog_size = 1073741824

# docker-compose.yml
version: '2'
services:
  mariadb:
    image: mariadb
    environment:
      - MYSQL_ROOT_PASSWORD=private_root_password
      - MYSQL_DATABASE=dms
      - MYSQL_USER=dms
      - MYSQL_PASSWORD=private_dms_password
    volumes:
      - "/var/lib/mysql:/var/lib/mysql"
      - "./config/mysql:/etc/mysql/conf.d:ro"
    ports:
      - 3306:3306

I uploaded my data structure dms-structures.sql to ftp.

Please let me know if you need anything else.
Thanks.

Comment by Elena Stepanova [ 2021-01-18 ]

I don't think we have ever had a chance to reproduce it without the data, given how specific conditions in the query are. Hopefully the problem was fixed in later versions in the scope of some other bug report along with numerous fixes in the area.

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