maria-discuss team mailing list archive
-
maria-discuss team
-
Mailing list archive
-
Message #05712
回复: 回复: [Maria-developers] 回复: [MariaDB 10.3.7] Hello, everyone. My process core dumped while calling mysql_ping().
-
To:
Markus Mäkelä <markus.makela@xxxxxxxxxxx>, "maria-discuss@xxxxxxxxxxxxxxxxxxx" <maria-discuss@xxxxxxxxxxxxxxxxxxx>, "maria-developers@xxxxxxxxxxxxxxxxxxx" <maria-developers@xxxxxxxxxxxxxxxxxxx>
-
From:
Ma Allen <mazhh@xxxxxxxxxxx>
-
Date:
Wed, 15 Jan 2020 06:51:37 +0000
-
Accept-language:
zh-CN, en-US
-
Arc-authentication-results:
i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none
-
Arc-message-signature:
i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jXemY1+EM6QSzApA0fg0XbBOtHzvz6e0XNHmIMrbQk8=; b=hbNwYgaTqxWh1AbDRED0KDK5O9ZhkuHwqgU1eFvTe3Fbgh1rsiGErMR66mO/1PkzvL1K7sRaCD5M9qhKQj3A2dITuNtOLZFztjA9qfMyiHu10LQV6LL9Yu3gFT5mD+MlkWMcWWtoVAZwkm9ZsWyEm7FGw2N9++oV1LPc9wfQw0s+gZhewbT4ieb1SaqsrTA3NnVSBmTFSXeOo9cRA/f7roW40GOllnlBvQlKvESqssf+iJr+igNgi3VeookKoZTc2EXtsK++5PWgE9ehD05zwby32ZDrmIvDdK/9yclWkaerpSTYMJYrDdc+e5wuhZnsdxlg8v+f2LkcK0mwaz0Qqw==
-
Arc-seal:
i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YDWo/48i/8E6Qsy0GDw0wG3fSBqF6uG0R2jrcpBcBCZnvZqE3d3gP39SozJNKWjG3e5xBwBcrUht9SgJTC7UmlGylZSicfvCQKh1H3nlYSBFpmF6yIpF6Zm12o0oOV9zZ1CdB4B6ruxuQOVL1qWwwowKMGWII8x/Rze2YfXOt7kc+VSwmU4pAhfVR0a7AqMfYoHxtftBsa6YDqcgSnDMb3O4Wy7dfATC8Towxj87Br9T/tjtjWNuYRgOJ8v2hOYl+2GLv3mBXV6Qv8SJ6yUcbpmiSvoh+dJy4YFnH0xFi8Ovs2wF44rpEA2wskX16d3S+9E4Zj3SBzK1ISQH9V+W0A==
-
In-reply-to:
<HK0PR03MB40826D8C7DBB557C31F5229BAA340@HK0PR03MB4082.apcprd03.prod.outlook.com>
-
Thread-index:
AQHVy3A7jPW6iKMKaE+uuuJKDjH4DQ==
-
Thread-topic:
回复: [Maria-discuss] 回复: [Maria-developers] 回复: [MariaDB 10.3.7] Hello, everyone. My process core dumped while calling mysql_ping().
Hi,
I've found the code where core dumped.
ssize_t ma_pvio_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t length)
{
ssize_t r= 0;
if (!pvio)
return -1;
if (IS_PVIO_ASYNC_ACTIVE(pvio)) // line 350
...
}
Line 350 carefully examines whether null pointer is used. And I can't find more clues.
#define IS_PVIO_ASYNC(a) \
((a)->mysql && (a)->mysql->options.extension && (a)->mysql->options.extension->async_context)
#define IS_PVIO_ASYNC_ACTIVE(a) \
(IS_PVIO_ASYNC(a)&& (a)->mysql->options.extension->async_context->active)
Allen
________________________________
发件人: Maria-discuss <maria-discuss-bounces+mazhh=outlook.com@xxxxxxxxxxxxxxxxxxx> 代表 Ma Allen <mazhh@xxxxxxxxxxx>
发送时间: 2020年1月14日 17:41
收件人: Markus Mäkelä <markus.makela@xxxxxxxxxxx>; maria-discuss@xxxxxxxxxxxxxxxxxxx <maria-discuss@xxxxxxxxxxxxxxxxxxx>; maria-developers@xxxxxxxxxxxxxxxxxxx <maria-developers@xxxxxxxxxxxxxxxxxxx>
主题: [Maria-discuss] 回复: [Maria-developers] 回复: [MariaDB 10.3.7] Hello, everyone. My process core dumped while calling mysql_ping().
Hi everyone,
I'd like to dig deeper into the MariaDB lib and find whether there would be more clues. However, I only got the MariaDB server installation package mariadb-10.2.6-linux-x86_64.tar.gz, which contains MariaDB lib as *.a and *.so. How can I get the corresponding source code of MariaDB lib? Many thanks in advance.
(gdb)
#0 ma_pvio_write (pvio=0x10101010101b2e0, buffer=buffer@entry=0x2510101 "\001", length=length@entry=5)
at /home/buildbot/buildbot/build/libmariadb/libmariadb/ma_pvio.c:350
#1 0x00007f7100249dea in ma_net_real_write (net=net@entry=0xee9de0 <g_mysql_info>, packet=0x2510101 "\001", len=5)
at /home/buildbot/buildbot/build/libmariadb/libmariadb/ma_net.c:335
#2 0x00007f7100249f60 in ma_net_flush (net=net@entry=0xee9de0 <g_mysql_info>) at /home/buildbot/buildbot/build/libmariadb/libmariadb/ma_net.c:166
#3 0x00007f710024a71a in ma_net_write_command (net=net@entry=0xee9de0 <g_mysql_info>, command=command@entry=14 '\016', packet=packet@entry=0x7f71003d6c67 "", len=0,
disable_flush=disable_flush@entry=0 '\000') at /home/buildbot/buildbot/build/libmariadb/libmariadb/ma_net.c:244
#4 0x00007f7100252ca4 in mthd_my_send_cmd (mysql=0xee9de0 <g_mysql_info>, command=<optimized out>, arg=0x7f71003d6c67 "", length=0, skipp_check=<optimized out>,
opt_arg=<optimized out>) at /home/buildbot/buildbot/build/libmariadb/libmariadb/mariadb_lib.c:394
#5 0x00007f71002518d0 in mysql_ping (mysql=0xee9de0 <g_mysql_info>) at /home/buildbot/buildbot/build/libmariadb/libmariadb/mariadb_lib.c:2552
BR,
Allen
________________________________
发件人: Maria-developers <maria-developers-bounces+mazhh=outlook.com@xxxxxxxxxxxxxxxxxxx> 代表 Ma Allen <mazhh@xxxxxxxxxxx>
发送时间: 2020年1月14日 17:04
收件人: Markus Mäkelä <markus.makela@xxxxxxxxxxx>; maria-discuss@xxxxxxxxxxxxxxxxxxx <maria-discuss@xxxxxxxxxxxxxxxxxxx>; maria-developers@xxxxxxxxxxxxxxxxxxx <maria-developers@xxxxxxxxxxxxxxxxxxx>
主题: [Maria-developers] 回复: [Maria-discuss] [MariaDB 10.3.7] Hello, everyone. My process core dumped while calling mysql_ping().
Hi Markus,
Only MySqlWaitConnected() in the two functions doesn't use lock, reading database uses mutex. What's more, the two functions in initialization relates to ONLY the main thread. No other threads call them.
Previously, the program is written with mysqllib, which is not MariaDB lib currently used. Mysqllib supports multiple threads to concurrently use one connection. Its tutorials were also referred to:
https://dev.mysql.com/doc/refman/5.7/en/c-api-threaded-clients.html
MySQL :: MySQL 5.7 Reference Manual :: 27.7.3.3 Writing C API Threaded Client Programs<https://dev.mysql.com/doc/refman/5.7/en/c-api-threaded-clients.html>
This section provides guidance for writing client programs that use the thread-related functions in the MySQL C API. For further information about these functions, see Section 27.7.11, “C API Threaded Function Descriptions”.For examples of source code that uses them, look in the client directory of a MySQL source distribution:
dev.mysql.com
After replacing mysqllib with MariaDB lib, everything works well on the test environment except one of the clients'.
Allen
________________________________
发件人: Maria-discuss <maria-discuss-bounces+mazhh=outlook.com@xxxxxxxxxxxxxxxxxxx> 代表 Markus Mäkelä <markus.makela@xxxxxxxxxxx>
发送时间: 2020年1月14日 15:40
收件人: maria-discuss@xxxxxxxxxxxxxxxxxxx <maria-discuss@xxxxxxxxxxxxxxxxxxx>
主题: Re: [Maria-discuss] [Maria-developers] [MariaDB 10.3.7] Hello, everyone. My process core dumped while calling mysql_ping().
Hi,
Is the connection protected by a lock of some sorts? To my knowledge the library does not support concurrent use of a single connection. I'd recommend trying to first wrap all access to the connection with a mutex and see if that solves the problem.
Markus
On 1/14/20 08:33, Ma Allen wrote:
Environment:
MariaDB 10.3.7 database server & related headers and libraries
CentOS 7.3 or 7.4
./configure --prefix=/home/spiderflow --localstatedir=/home/spiderflow --enable-unix-socket --with-libnss-libraries=/usr/lib64 --with-libnss-includes=/usr/include/nss3 --with-libnspr-libraries=/usr/lib64 --with-libnspr-includes=/usr/include/nspr4 --enable-netmap --enable-rust --disable-gccmarch-native --enable-mysql --with-libmysql-includes=/usr/local/mariadb-10.3.7-linux-systemd-x86_64/include/mysql --with-libmysql-libraries=/usr/local/mariadb-10.3.7-linux-systemd-x86_64/lib
Phenomenon:
(gdb)
#0 ma_pvio_write (pvio=0x10101010101b2e0, buffer=buffer@entry=0x2510101 "\001", length=length@entry=5)
at /home/buildbot/buildbot/build/libmariadb/libmariadb/ma_pvio.c:350
#1 0x00007f7100249dea in ma_net_real_write (net=net@entry=0xee9de0 <g_mysql_info>, packet=0x2510101 "\001", len=5)
at /home/buildbot/buildbot/build/libmariadb/libmariadb/ma_net.c:335
#2 0x00007f7100249f60 in ma_net_flush (net=net@entry=0xee9de0 <g_mysql_info>) at /home/buildbot/buildbot/build/libmariadb/libmariadb/ma_net.c:166
#3 0x00007f710024a71a in ma_net_write_command (net=net@entry=0xee9de0 <g_mysql_info>, command=command@entry=14 '\016', packet=packet@entry=0x7f71003d6c67 "", len=0,
disable_flush=disable_flush@entry=0 '\000') at /home/buildbot/buildbot/build/libmariadb/libmariadb/ma_net.c:244
#4 0x00007f7100252ca4 in mthd_my_send_cmd (mysql=0xee9de0 <g_mysql_info>, command=<optimized out>, arg=0x7f71003d6c67 "", length=0, skipp_check=<optimized out>,
opt_arg=<optimized out>) at /home/buildbot/buildbot/build/libmariadb/libmariadb/mariadb_lib.c:394
#5 0x00007f71002518d0 in mysql_ping (mysql=0xee9de0 <g_mysql_info>) at /home/buildbot/buildbot/build/libmariadb/libmariadb/mariadb_lib.c:2552
#6 0x00000000006651b2 in MySqlWaitConnected (p_mysql_data=p_mysql_data@entry=0xee9de0 <g_mysql_info>) at ../srcSF/spiderFlow-proto-baseline.c:676
#7 0x0000000000668819 in LoadProtoConfInfos (pInfo=pInfo@entry=0xee9de0 <g_mysql_info>) at ../srcSF/spiderFlow-proto-baseline.c:835
#8 0x000000000066c53a in InitBaseLine () at ../srcSF/spiderFlow-proto-baseline.c:1069
#9 0x00000000005f308b in PostConfLoadedSetup (suri=0x10dbb80 <suricata>) at suricata.c:2900
#10 0x0000000000425ce8 in main (argc=5, argv=0x7fff1cdca258) at suricata.c:3072
(gdb)
Analyzation:
The core dump always exists after running for a while or maybe after the sever restarts. It occurs at the initialization and involves with ONLY ONE thread, which is the main thread of the whole process.
The related code is two functions, which both checks the connection and read data from MariaDB. The first function works fine, however, the second one's checking connection leads to core dump.
The code to check connection is as follows:
void MySqlWaitConnected(MYSQL * p_mysql_data)
{
while (mysql_ping(p_mysql_data) != 0) {
SCLogInfo("Mysql ping error:%s", mysql_error(p_mysql_data));
#ifdef WIN32
Sleep(3000);
#else
sleep(3);
#endif
}
}
Previously, I solved a likely similar problem as follows:
Multiple threads shared ONE MySQL handler, which is the MYSQL data structure. Before inserting data into MariaDB without mutex, MySqlWaitConnected() is called. So while multiple threads do the same operation, inserting data is interrupted by mysql_ping() that leads to core dump. Afterwards, I comment MySqlWaitConnected() and add mutex for mysql_real_query() and mysql_commit().
Does anyone meet the same problem before? Any suggestion is appreciated. Thanks in advance.
Best Regards,
Allen Ma
_______________________________________________
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@xxxxxxxxxxxxxxxxxxx<mailto:maria-developers@xxxxxxxxxxxxxxxxxxx>
Unsubscribe : https://launchpad.net/~maria-developers
More help : https://help.launchpad.net/ListHelp
--
Markus Mäkelä, Senior Software Engineer
MariaDB Corporation
t: +358 40 7740484 | IRC: markusjm@freenode
References