[MDEV-24028] Server crash after running a query Created: 2020-10-26  Updated: 2020-10-26  Resolved: 2020-10-26

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - Window functions
Affects Version/s: 10.3.25
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Pavel Znamensky Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Environment:

CentOS Linux release 7.8.2003 (Core)


Attachments: File dump.sql    
Issue Links:
Duplicate
duplicates MDEV-15178 Filesort::make_sortorder: Assertion `... Closed

 Description   

Our server crashes after executing a query with the following message:

systemd[1]: Started MariaDB 10.3.25 database server.
mysqld[18815]: 2020-10-26 15:43:23 0 [Note] InnoDB: Buffer pool(s) load completed at 201026 15:43:23
mysqld[18815]: 201026 15:50:20 [ERROR] mysqld got signal 11 ;
mysqld[18815]: This could be because you hit a bug. It is also possible that this binary
mysqld[18815]: or one of the libraries it was linked against is corrupt, improperly built,
mysqld[18815]: or misconfigured. This error can also be caused by malfunctioning hardware.
mysqld[18815]: To report this bug, see https://mariadb.com/kb/en/reporting-bugs
mysqld[18815]: We will try our best to scrape up some info that will hopefully help
mysqld[18815]: diagnose the problem, but since we have already crashed,
mysqld[18815]: something is definitely wrong and this may fail.
mysqld[18815]: Server version: 10.3.25-MariaDB-log
mysqld[18815]: key_buffer_size=134217728
mysqld[18815]: read_buffer_size=2097152
mysqld[18815]: max_used_connections=2
mysqld[18815]: max_threads=802
mysqld[18815]: thread_count=9
mysqld[18815]: It is possible that mysqld could use up to
mysqld[18815]: key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 8361599 K  bytes of memory
mysqld[18815]: Hope that's ok; if not, decrease some variables in the equation.
mysqld[18815]: Thread pointer: 0x7f6fbc0009a8
mysqld[18815]: Attempting backtrace. You can use the following information to find out
mysqld[18815]: where mysqld died. If you see no messages after this, something went
mysqld[18815]: terribly wrong...
mysqld[18815]: stack_bottom = 0x7f74301dcd30 thread_stack 0x49000
mysqld[18815]: /usr/sbin/mysqld(my_print_stacktrace+0x2e)[0x561610e1bcde]
mysqld[18815]: /usr/sbin/mysqld(handle_fatal_signal+0x30f)[0x5616108b120f]
mysqld[18815]: sigaction.c:0(__restore_rt)[0x7f743a9fe630]
mysqld[18815]: /usr/sbin/mysqld(_Z8filesortP3THDP5TABLEP8FilesortP16Filesort_trackerP4JOINy+0x30d)[0x5616108af71d]
mysqld[18815]: /usr/sbin/mysqld(_Z17create_sort_indexP3THDP4JOINP13st_join_tableP8Filesort+0xd7)[0x561610717037]
mysqld[18815]: /usr/sbin/mysqld(_ZN17Window_funcs_sort4execEP4JOINb+0x4a)[0x56161080d73a]
mysqld[18815]: /usr/sbin/mysqld(_ZN24Window_funcs_computation4execEP4JOINb+0x2a)[0x56161080d7ea]
mysqld[18815]: /usr/sbin/mysqld(_ZN7AGGR_OP8end_sendEv+0xec)[0x561610722f2c]
mysqld[18815]: /usr/sbin/mysqld(_Z24sub_select_postjoin_aggrP4JOINP13st_join_tableb+0x31)[0x561610723101]
mysqld[18815]: /usr/sbin/mysqld(_ZN4JOIN10exec_innerEv+0x93b)[0x561610729a0b]
mysqld[18815]: /usr/sbin/mysqld(_ZN4JOIN4execEv+0x33)[0x561610729d73]
mysqld[18815]: /usr/sbin/mysqld(_Z12mysql_selectP3THDP10TABLE_LISTjR4ListI4ItemEPS4_jP8st_orderS9_S7_S9_yP13select_resultP18st_select_lex_unitP13st_select_lex+0x11a)[0x56161072827a]
mysqld[18815]: /usr/sbin/mysqld(_Z18mysql_derived_fillP3THDP3LEXP10TABLE_LIST+0x16b)[0x5616106983ab]
mysqld[18815]: /usr/sbin/mysqld(_Z27mysql_handle_single_derivedP3LEXP10TABLE_LISTj+0xfc)[0x5616106980bc]
mysqld[18815]: /usr/sbin/mysqld(_ZN13st_join_table12preread_initEv+0x79)[0x561610705959]
mysqld[18815]: /usr/sbin/mysqld(_Z10sub_selectP4JOINP13st_join_tableb+0x2f8)[0x561610705d18]
mysqld[18815]: /usr/sbin/mysqld(_ZN4JOIN10exec_innerEv+0xa8b)[0x561610729b5b]
mysqld[18815]: /usr/sbin/mysqld(_ZN4JOIN4execEv+0x33)[0x561610729d73]
mysqld[18815]: /usr/sbin/mysqld(_Z12mysql_selectP3THDP10TABLE_LISTjR4ListI4ItemEPS4_jP8st_orderS9_S7_S9_yP13select_resultP18st_select_lex_unitP13st_select_lex+0x11a)[0x56161072827a]
mysqld[18815]: /usr/sbin/mysqld(_Z13handle_selectP3THDP3LEXP13select_resultm+0x1cc)[0x561610728d8c]
mysqld[18815]: /usr/sbin/mysqld(+0x4daf16)[0x5616105d8f16]
mysqld[18815]: /usr/sbin/mysqld(_Z21mysql_execute_commandP3THD+0x63ba)[0x5616106d18da]
mysqld[18815]: /usr/sbin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_statebb+0x36d)[0x5616106d464d]
mysqld[18815]: /usr/sbin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcjbb+0xfe1)[0x5616106d5ee1]
mysqld[18815]: /usr/sbin/mysqld(_Z10do_commandP3THD+0x11b)[0x5616106d817b]
mysqld[18815]: /usr/sbin/mysqld(_Z24do_handle_one_connectionP7CONNECT+0x1d6)[0x5616107aea96]
mysqld[18815]: /usr/sbin/mysqld(handle_one_connection+0x3d)[0x5616107aebad]
mysqld[18815]: pthread_create.c:0(start_thread)[0x7f743a9f6ea5]
mysqld[18815]: /lib64/libc.so.6(clone+0x6d)[0x7f7438d978dd]
mysqld[18815]: Trying to get some variables.
mysqld[18815]: Some pointers may be invalid and cause the dump to abort.
mysqld[18815]: Query (0x7f6fbc0114e0): with cte as ( SELECT     lb.bmgame_id   , rum.legal_owner_id   , lo.title   , sum(revenue)   ,  count(DISTINCT rum.external_user_id)   , row_number() OVER ( partition by lb.bmgame_id order by count( rum.external_user_id) desc ) as rn FROM     reports_user_monthlies as rum join     legal_games as lb     ON rum.legal_game_id = lb.id join     legal_owners as lo     on lo.id = rum.legal_owner_id WHERE     month BETWEEN mgame_id is not null GROUP BY     lb.bmgame_id   , rum.legal_owner_id ) select bmgame_id, count(*) From cte group by 1 having count(*) > 1
systemd[1]: mariadb.service: main process exited, code=killed, status=11/SEGV
systemd[1]: Unit mariadb.service entered failed state.
systemd[1]: mariadb.service failed.

The query is:

with cte as (
SELECT
    lb.bmgame_id
  , rum.legal_owner_id
  , lo.title
  , sum(revenue)
  ,  count(DISTINCT rum.external_user_id)
  , row_number() OVER ( partition by lb.bmgame_id order by count( rum.external_user_id) desc ) as rn
FROM
    reports_user_monthlies as rum
join
    legal_games as lb
    ON rum.legal_game_id = lb.id
join
    legal_owners as lo
    on lo.id = rum.legal_owner_id
WHERE
    month BETWEEN '2020-07-01' AND '2020-09-01'
    and bmgame_id is not null
GROUP BY
    lb.bmgame_id
  , rum.legal_owner_id
)
select bmgame_id, count(*) From cte group by 1 having count(*) > 1

Tables shemas you can find in the attachments.



 Comments   
Comment by Alice Sherepa [ 2020-10-26 ]

Thanks for the report!
I reproduced as described on 10.2-10.5, it is the same problem as MDEV-15178, on debug version it fails with assertion `pos->field != __null || pos->item != __null' in Filesort::make_sortorder:

10.2 784473b986625c25a7a

Version: '10.2.35-MariaDB-debug-log' 
mysqld: /10.2/sql/filesort.cc:502: uint Filesort::make_sortorder(THD*, JOIN*, table_map): Assertion `pos->field != __null || pos->item != __null' failed.
201026 14:45:36 [ERROR] mysqld got signal 6 ;
 
Server version: 10.2.35-MariaDB-debug-log
 
linux/raise.c:51(__GI_raise)[0x7f0aaf995859]
stdlib/abort.c:81(__GI_abort)[0x7f0aaf995729]
intl/loadmsgcat.c:509(get_sysdep_segment_value)[0x7f0aaf9a6f36]
sql/filesort.cc:457(Filesort::make_sortorder(THD*, JOIN*, unsigned long long))[0x564b08b94828]
sql/filesort.cc:159(filesort(THD*, TABLE*, Filesort*, Filesort_tracker*, JOIN*, unsigned long long))[0x564b08992a9e]
sql/sql_select.cc:22062(create_sort_index(THD*, JOIN*, st_join_table*, Filesort*))[0x564b08aed716]
sql/sql_window.cc:2804(Window_funcs_sort::exec(JOIN*, bool))[0x564b08aedc56]
sql/sql_window.cc:2937(Window_funcs_computation::exec(JOIN*, bool))[0x564b0899fd16]
sql/sql_select.cc:26850(AGGR_OP::end_send())[0x564b0898a7b5]
sql/sql_select.cc:18574(sub_select_postjoin_aggr(JOIN*, st_join_table*, bool))[0x564b0898aae9]
sql/sql_select.cc:18810(sub_select(JOIN*, st_join_table*, bool))[0x564b0898aae9]
sql/sql_select.cc:18810(sub_select(JOIN*, st_join_table*, bool))[0x564b0898aae9]
sql/sql_select.cc:18810(sub_select(JOIN*, st_join_table*, bool))[0x564b0898a2e1]
sql/sql_select.cc:18405(do_select(JOIN*, Procedure*))[0x564b08963ee5]
sql/sql_select.cc:3641(JOIN::exec_inner())[0x564b0896338c]
sql/sql_select.cc:3437(JOIN::exec())[0x564b0896454e]
sql/sql_select.cc:3838(mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x564b088eaf72]
sql/sql_derived.cc:1084(mysql_derived_fill(THD*, LEX*, TABLE_LIST*))[0x564b088e8ee2]
sql/sql_derived.cc:198(mysql_handle_single_derived(LEX*, TABLE_LIST*, unsigned int))[0x564b0897a85b]
sql/sql_select.cc:12108(st_join_table::preread_init())[0x564b0898ab73]
sql/sql_select.cc:18827(sub_select(JOIN*, st_join_table*, bool))[0x564b0898a288]
sql/sql_select.cc:18403(do_select(JOIN*, Procedure*))[0x564b08963ee5]
sql/sql_select.cc:3641(JOIN::exec_inner())[0x564b0896338c]
sql/sql_select.cc:3437(JOIN::exec())[0x564b0896454e]
sql/sql_select.cc:3838(mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x564b089586c8]
sql/sql_select.cc:361(handle_select(THD*, LEX*, select_result*, unsigned long))[0x564b08923267]
sql/sql_parse.cc:6218(execute_sqlcom_select(THD*, TABLE_LIST*))[0x564b08919bb6]
sql/sql_parse.cc:3527(mysql_execute_command(THD*))[0x564b08926ff5]
sql/sql_parse.cc:7733(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x564b08915392]
sql/sql_parse.cc:1829(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x564b08913e8d]
sql/sql_parse.cc:1380(do_command(THD*))[0x564b08a6dce5]
sql/sql_connect.cc:1336(do_handle_one_connection(CONNECT*))[0x564b08a6da4a]
sql/sql_connect.cc:1242(handle_one_connection)[0x564b09292600]
nptl/pthread_create.c:478(start_thread)[0x7f0aafeb8609]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x43)[0x7f0aafa92293]
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7f0a5c0126f8): with cte as (
SELECT
lb.bmgame_id
, rum.legal_owner_id
, lo.title
, sum(revenue)
,  count(DISTINCT rum.external_user_id)
, row_number() OVER ( partition by lb.bmgame_id order by count( rum.external_user_id) desc ) as rn
FROM
reports_user_monthlies as rum
join
legal_games as lb
ON rum.legal_game_id = lb.id
join
legal_owners as lo
on lo.id = rum.legal_owner_id
WHERE
month BETWEEN '2020-07-01' AND '2020-09-01'
    and bmgame_id is not null
GROUP BY
lb.bmgame_id
, rum.legal_owner_id
)
select bmgame_id, count(*) From cte group by 1 having count(*) > 1
 
Connection ID (thread ID): 9
Status: NOT_KILLED

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