About Mysql-proxy child process exception exit bug fix

Source: Internet
Author: User
Tags lua

I have already mentioned in my previous blog post the problem with the Mysql-proxy child process exiting abnormally:

http://sofar.blog.51cto.com/353572/1398820


The associated error message is as follows:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/27/A0/wKiom1NzgvWjFannAAD5B9ytl8U654.jpg "title=" Bug.jpg "alt=" Wkiom1nzgvwjfannaad5b9ytl8u654.jpg "/>


By looking at signal number 11th, SIGSEGV indicates that the process has executed an invalid memory reference or a segment error, causing the child process to exit unexpectedly.


we know that Mysql-proxy is using a parent-child process pattern, that processing requests are done by a child process, and that the parent process acts only as a daemon, and we typically add the Mysql-proxy in the configuration file " keepalive=true " parameter to ensure that the parent process automatically pulls the child process out when it exits unexpectedly.


Just started to locate the following two source files:

Src/chassis-unix-daemon.c

Src/chassis-mainloop.c


In which the processing of the sigterm/sigint/sighup three signals is seen, and a similar method is added to the processing of the SIGSEGV signal (ignoring the signal), the modification is as follows:

SRC/CHASSIS-UNIX-DAEMON.C:

Signal (SIGSEGV, chassis_unix_signal_forward); signal (SIGSEGV, SIG_DFL);

SRC/CHASSIS-MAINLOOP.C:

struct event ev_sigterm, Ev_sigint, Ev_sigsegv;......signal_set (&EV_SIGSEGV, SIGSEGV, Sigsegv_handler, NULL); Event_base_set (Chas->event_base, &EV_SIGSEGV); Signal_add (&EV_SIGSEGV, NULL); Signal_del (&ev_ SIGSEGV);

Although no longer error, also can work normally, but not good, 5 minutes or so hanging off. Because we ignore the SIGSEGV signal, when the child process exits abnormally, the parent process does not receive the SIGSEGV signal that caused the child process to exit abnormally, and of course it cannot pull the child process up normally, so this method does not solve our problem.


Since the above method does not solve our problem, so we think of the way to open coredump debug tracking, set the following:

# ulimit-c Unlimited

# echo "1" >/proc/sys/kernel/core_uses_pid

# mkdir-p/root/corefile

# echo "/root/corefile/core-%e-%p-%t" >/proc/sys/kernel/core_pattern


Recompile Mysql-proxy (note to add " - G " parameters):

#./configure--prefix=/usr/local/mysql-proxy \

--with-lua=/usr/local/lua \

--with-mysql=/usr/local/mysql \

glib_cflags= "-i/usr/local/glib-2.32.4/include/glib-2.0" \

glib_libs= "-l/usr/local/glib-2.32.4/lib/glib-2.0-lglib-2.0" \

gmodule_cflags= "-i/usr/local/glib-2.32.4/include" \

gmodule_libs= "-l/usr/local/glib-2.32.4/lib-lgmodule-2.0" \

gthread_cflags= "-i/usr/local/glib-2.32.4/include" \

gthread_libs= "-l/usr/local/glib-2.32.4/lib-lgthread-2.0" \

ldflags= "-l/usr/local/lib-lm-l/usr/local/lib64-lcrypto" \

lua_cflags= "-i/usr/local/lua/include" \

lua_libs= "-L/USR/LOCAL/LUA/LIB-LLUA-5.1-LDL" \

cflags= "-dhave_lua_h - G "

# Make && make install


Start the compiled Mysql-proxy program again, and the following core files will be generated in a few minutes:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/27/A1/wKioL1Nzi2mRjUFhAADGn4lGnSY989.jpg "title=" Coredump.jpg "alt=" Wkiol1nzi2mrjufhaadgn4lgnsy989.jpg "/>


Use GDB for trace debugging:

# Cd/usr/local/mysql-proxy/bin

# GDB./mysql-proxy/root/corefile/core-mysql-proxy-32354-1400039241


Get the following information:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/27/A0/wKiom1NzjJ3i0_0NAAZ_AC2W-3c875.jpg "title=" Coredump.png "alt=" Wkiom1nzjj3i0_0naaz_ac2w-3c875.jpg "/>


By referencing 360 of the Atlas source, we eventually navigate to the Network_connection_pool_lua_add_connection function in NETWORK-CONN-POOL-LUA.C, modified as follows:

Before modification:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/27/A1/wKioL1Nzjh6xkpOVAAIGft5rj1M476.jpg "title=" Mysql-proxy1.jpg "alt=" Wkiol1nzjh6xkpovaaigft5rj1m476.jpg "/>


After modification:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/27/A1/wKioL1NzjnriuyOHAAO2a7CT45o672.jpg "title=" Mysql-proxy2.jpg "alt=" Wkiol1nzjnriuyohaao2a7ct45o672.jpg "/>


We can in the map of the corresponding modification of the location, see the following information, I think you should understand what caused it!!!

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/27/A2/wKiom1NzlFSB0e0cAADxomzYh-0520.jpg "title=" Bugfix.jpg "alt=" Wkiom1nzlfsb0e0caadxomzyh-0520.jpg "/>


after testing, everything OK!!! 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0067.gif "alt=" J_0067.gif "/>



This article from "The ideal of life is Perseverance" blog, please be sure to keep this source http://sofar.blog.51cto.com/353572/1411344

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.