简体   繁体   中英

MySQL Server stops running on specific query sent from C# application

I am developing a C# program which interacts with a database that runs on MySQL Server.

Out of the many queries this program performs on this database, one of them is as follows.

As sent from C# program:

string query = $"select * from ((select id,title from wikipedia where lang like ('{string.Join(",", pLang)}') and title<>'') union all (select id, redirect 'title' from redirect where lang like '{string.Join(",", pLang)}' and redirect<>''))r;";

As the string sent to the database:

select * from ((select id,title from wikipedia where lang like ('en') and title<>'') union all (select id, redirect 'title' from redirect where lang like 'en' and redirect<>''))r;

Ocasionally, this database's MySQL Server will shutdown upon performing this specific query (it has not happened with any other query so far) The first time i've spotted this issue was a couple of days after changing from a small subset of data used for testing to a larger set of data which will need to work with periodically.

Currently the tables used on that query hold ~7800000 and ~699000 rows respectively.

Whenever this happens, the Server will shutdown immediately after the program sends the query.

Error log:

10:03:31 UTC - mysqld got exception 0xc0000005 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
Thread pointer: 0x12d7ded4390
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...
7ff7d8e82c1e    mysqld.exe!?strncpyz@Event_reader@binary_log@@QEAAXPEAD_K1@Z()
7ff7d8e7f8f9    mysqld.exe!?strncpyz@Event_reader@binary_log@@QEAAXPEAD_K1@Z()
7ff7d7f577ed    mysqld.exe!?free_tmp_table@@YAXPEAVTHD@@PEAUTABLE@@@Z()
7ff7d7efb21f    mysqld.exe!?deallocate@?$allocator@V?$unique_ptr@VRowIterator@@V?$Destroy_only@VRowIterator@@@@@std@@@std@@QEAAXQEAV?$unique_ptr@VRowIterator@@V?$Destroy_only@VRowIterator@@@@@2@_K@Z()
7ff7d7efa3f7    mysqld.exe!?cleanup@SELECT_LEX@@QEAA_NPEAVTHD@@_N@Z()
7ff7d7efa4ff    mysqld.exe!?cleanup@SELECT_LEX_UNIT@@QEAA_NPEAVTHD@@_N@Z()
7ff7d7d83289    mysqld.exe!?mysql_execute_command@@YAHPEAVTHD@@_N@Z()
7ff7d7d839c4    mysqld.exe!?mysql_parse@@YAXPEAVTHD@@PEAVParser_state@@@Z()
7ff7d7d7cb60    mysqld.exe!?dispatch_command@@YA_NPEAVTHD@@PEBTCOM_DATA@@W4enum_server_command@@@Z()
7ff7d7d7dade    mysqld.exe!?do_command@@YA_NPEAVTHD@@@Z()
7ff7d7bfcfc8    mysqld.exe!?modify_thread_cache_size@Per_thread_connection_handler@@SAXK@Z()
7ff7d8e087a1    mysqld.exe!?strncpyz@Event_reader@binary_log@@QEAAXPEAD_K1@Z()
7ff7d8a4606c    mysqld.exe!?my_thread_join@@YAHPEAUmy_thread_handle@@PEAPEAX@Z()
7ffe89991ffa    ucrtbase.dll!_o_exp()
7ffe8a577974    KERNEL32.DLL!BaseThreadInitThunk()
7ffe8d38a261    ntdll.dll!RtlUserThreadStart()

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (12d7e5f0c98): select * from ((select id,title from wikipedia where lang like ('en') and title<>'') union all (select id, redirect 'title' from redirect where lang like 'en' and redirect<>''))r
Connection ID (thread ID): 66
Status: NOT_KILLED

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.
2020-04-15T10:04:19.511132Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2020-04-15T10:04:19.515876Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.19) starting as process 5660
2020-04-15T10:04:22.501909Z 0 [System] [MY-010229] [Server] Starting XA crash recovery...
2020-04-15T10:04:22.510760Z 0 [System] [MY-010232] [Server] XA crash recovery finished.
2020-04-15T10:04:23.072748Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-04-15T10:04:23.119390Z 0 [System] [MY-010931] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: ready for connections. Version: '8.0.19'  socket: ''  port: 3306  MySQL Community Server - GPL.
2020-04-15T10:04:23.276080Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060

Slow log:

SET timestamp=1586941541;
select distinct(id) from wikipedia where lang like ('es');
# Time: 2020-04-15T09:09:10.701455Z
# User@Host: root[root] @ localhost [127.0.0.1]  Id:    63
# Query_time: 104.064637  Lock_time: 0.000074 Rows_sent: 6578886  Rows_examined: 8306925
SET timestamp=1586941646;
select distinct(id) from wikipedia where lang like ('en');
# Time: 2020-04-15T10:02:11.919601Z
# User@Host: root[root] @ localhost [127.0.0.1]  Id:    65
# Query_time: 26.851506  Lock_time: 0.001500 Rows_sent: 2969442  Rows_examined: 2969442
SET timestamp=1586944905;
select * from ((select id,title from wikipedia where lang like ('es') and title<>'') union all (select id, redirect 'title' from redirect where lang like 'es' and redirect<>''))r;
C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe, Version: 8.0.19 (MySQL Community Server - GPL). started with:
TCP Port: 3306, Named Pipe: MySQL
Time                 Id Command    Argument

Over the past week I've been trying to find the cause of this problem but I can't seem to reproduce it at will. Sometimes the query will be answered without issue (when sent from the program), as shown in the slow log:

# Time: 2020-04-15T06:04:55.984006Z
# User@Host: root[root] @ localhost [127.0.0.1]  Id:    60
# Query_time: 74.830395  Lock_time: 0.000663 Rows_sent: 12234243  Rows_examined: 12234243
SET timestamp=1586930621;
select * from ((select id,title from wikipedia where lang like ('en') and title<>'') union all (select id, redirect 'title' from redirect where lang like 'en' and redirect<>''))r;

I have also tried executing the query directly from MySQL Workbench multiple times (but again, not reproducing the Server shutdown. As shown below)

LIMIT 0, 1000;
# Time: 2020-04-15T14:33:01.406478Z
# User@Host: root[root] @ localhost [::1]  Id:    15
# Query_time: 22.342847  Lock_time: 0.002968 Rows_sent: 12234315  Rows_examined: 12234315
SET timestamp=1586961159;
select * from ((select id,title from wikipedia where lang like ('en') and title<>'') union all (select id, redirect 'title' from redirect where lang like 'en' and redirect<>''))r limit 1000000000;
# Time: 2020-04-15T14:36:12.223454Z
# User@Host: root[root] @ localhost [::1]  Id:    15
# Query_time: 22.223628  Lock_time: 0.000161 Rows_sent: 12234315  Rows_examined: 12234315
SET timestamp=1586961349;
select * from ((select id,title from wikipedia where lang like ('en') and title<>'') union all (select id, redirect 'title' from redirect where lang like 'en' and redirect<>''))r limit 1000000000;

Thank you for reading this far, and thank you beforehand for any help/suggestion you might provide.

As per the failure message:

Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.

The first thing to do would be to rule out malfunctioning hardware (most likely RAM). Since it looks like you're running on Windows, use the built-in Windows Memory Diagnostic to run a stress test of your RAM.

Then review the list of steps to take when MySQL Server is crashing at https://dev.mysql.com/doc/refman/8.0/en/crashing.html

If none of those help, you can report a bug (at https://bugs.mysql.com/ ) following the steps at https://dev.mysql.com/doc/refman/8.0/en/bug-reports.html

Note that it will help greatly to have a consistently reproducible test case, so the MySQL developers can reproduce the problem and fix it. Otherwise, the bug may be closed "not reproducible". The more you can do to make the crash happen consistently, the better.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM