日期:2014-05-16  浏览次数:20985 次

linux mysql c 客户端丢失链接后崩溃!
mysql_real_query 调用此函数的时候返回一个错误

Lost connection to MySQL server during query


然后我程序就崩溃了。。。
怎么解决这个问题呐? 我用的是6.0.4的MYSQL C 库,用的.a 的  是不是用MYSQL。SO的好要点?
我程序没有任何问题,SQL语句也没问题,我们这边服务器网络不稳定,但是丢失链接后也不应该让我服务器崩溃啊


(gdb) bt
#0  0xb779c424 in __kernel_vsyscall ()
#1  0xb752c1df in raise () from /lib/i386-linux-gnu/libc.so.6
#2  0xb752f825 in abort () from /lib/i386-linux-gnu/libc.so.6
#3  0xb756939a in ?? () from /lib/i386-linux-gnu/libc.so.6
#4  0xb7573ee2 in ?? () from /lib/i386-linux-gnu/libc.so.6
#5  0xb72e904e in my_no_flags_free (ptr=0x0) at /export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/mysys/my_malloc.c:65
#6  0xb72ca4a6 in end_server (mysql=0xb1d720b4) at /export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/libmysql/client.c:1033
#7  0xb72ca0fa in cli_safe_read (mysql=0xb1d720b4) at /export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/libmysql/client.c:688
#8  0xb72ccb36 in cli_read_query_result (mysql=0xb1d720b4) at /export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/libmysql/client.c:2825
#9  0xb72ccddc in mysql_real_query (mysql=0xb1d720b4, 
    query=0xb1d728bc "INSERT INTO `data_netflow_2013-04-18` (`host_ip`,`host_mac`,`up_flow`,`down_flow`,`http_up`,`http_down`,`http_total`,`smtp_up`,`smtp_down`,`smtp_total`,`pop3_up`,`pop3_down`,`pop3_total`,`ftp_up`,`ftp"..., length=510)
    at /export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/libmysql/client.c:2912
#10 0xb72c76d3 in CDataBase_MySQL::DataBase_MySQL_Execute (this=0xb7479f60 <m_MySQL>, xhNet=665, 
    lpszSQLQuery=0xb1d728bc "INSERT INTO `data_netflow_2013-04-18` (`host_ip`,`host_mac`,`up_flow`,`down_flow`,`http_up`,`http_down`,`http_total`,`smtp_up`,`smtp_down`,`smtp_total`,`pop3_up`,`pop3_down`,`pop3_total`,`ftp_up`,`ftp"...) at ./DataBase_MySql/DataBase_MySql.cpp:154
#11 0xb72c9d4a in DataBase_MySQL_Execute (xhData=665, 
    lpszSQLQuery=0xb1d728bc "INSERT INTO `data_netflow_2013-04-18` (`host_ip`,`host_mac`,`up_flow`,`down_flow`,`http_up`,`http_down`,`http_total`,`smtp_up`,`smtp_down`,`smtp_total`,`pop3_up`,`pop3_down`,`pop3_total`,`ftp_up`,`ftp"...) at ./DataBase_DllMain.cpp:45
#12 0xb773d651 in CLogicWork_Flow::LogicWork_Flow_InsertStorage (this=0xb7745030 <m_LogicFlow>, pSt_XMLFLow=0xb1d7312c) at ./Logic_ProWorkFlow/Logic_ProWorkFlow.cpp:55
#13 0xb7740fd5 in LogicWork_Flow_InsertStorage (pSt_XMLFLow=0xb1d7312c) at ./ProWork_DllMain.cpp:63
#14 0xb77300f0 in CDetachLayer_Dispatch::DetachLayer_Dispatch_Flow (this=0xb7738048 <m_Dispatch>, 
    lpszPacket=0xb0201d7a "<netflow><host_ip>::2ff:0:0:90db:75b7</host_ip><host_mac>333300010002</host_mac><up_flow>2252</up_flow><down_flow>21713</down_flow><proto><up><ftp>0</ftp><telnet>0</telnet><smtp>0</smtp><http>0</http>"..., nLen=413) at ./DetachLayer_Dispatch/DetachLayer_Dispatch.cpp:187
#15&nb