dizzyd / erlang-mysql-driver Goto Github PK
View Code? Open in Web Editor NEWErlang MySQL Driver (from code.google.com)
License: Other
Erlang MySQL Driver (from code.google.com)
License: Other
When I start mysql:init/1, mysql_conn:start/8 returns {error, Reason}, but mysql_recv process has started. I will lead mysql connect hold, mysql will reach max connection as soon as possable.
Test Case:
You can use a database name that not creates.
The fix is to just add a new function header to mysql_auth:password_new:
<<>>;
MySQL returns e.g. the double 0.0000000000000001 as 1E-16, which cannot be parsed by erlang-mysql-driver. Instead it returns the integer 1.
A fix for this problem has already been committed at jkvor/emysql@9970fa7.
I had a trouble about firewall when I use this library.The phenomenon is: mysql client A which uses erlang-mysql-driver library connect to mysql server B,and can access to B normal.But after two hours the socket is prevented by firewall,the Keep-Alive msg from B to A is prevented by firewall,the socket is broken,but A don't know!When A send a mysql query msg to B ,then would get a msg said "Failed sending data on socket",Nor would reconnect to B.
By reading the source code,we know A will reconnect to B only when A receive a "tcp_closed" msg,ie,a tcp_fin msg.So A will not receive "tcp_closed"/tcp_fin msg when firewall work or the socket is broken in some way,nor will reconnect to B.And A will not remove the connection.All of operations just get a return value "Failed sending data on socket".
So my solution is that add some codes in mysql_conn.erl:470 of do_query(Sock, RecvPid, LogFun, Query, Version)
gen_tcp:close(Sock), RecvPid ! {tcp_closed, Sock},
That is,when do_send() error,we close this socket,and product a tcp_closed msg,send to the RecvPid.This can notice RecvPid to trigger the reconnection.
Finally,the author add code for mysql heartbeat and reconnect automatically is the best way!
hi ,dave
this error message occur in my servers, i have no idea what happen ,would you help me.
socket will be close when mysql_recv get the tcp_closed message, and stop the mysql_conn loop/0,
it seems that the socket was already closed, but the loop is not over , does it nomal ?
if mysql socket closed (my be the network broken)
when i fetch
finally go to here:
do_recv(LogFun, RecvPid, SeqNum) when is_function(LogFun);
LogFun == undefined,
SeqNum == undefined ->
receive
{mysql_recv, RecvPid, data, Packet, Num} ->
{ok, Packet, Num};
{mysql_recv, RecvPid, closed, _E} ->
{error, io_lib:format("mysql_recv: socket was closed ~p", [_E])}
end;
do_recv(LogFun, RecvPid, SeqNum) when is_function(LogFun);
LogFun == undefined,
is_integer(SeqNum) ->
ResponseNum = SeqNum + 1,
receive
{mysql_recv, RecvPid, data, Packet, ResponseNum} ->
{ok, Packet, ResponseNum};
{mysql_recv, RecvPid, closed, _E} ->
{error, io_lib:format("mysql_recv: socket was closed ~p", [_E])}
end.
this function return {error, Reason}
the mysql_conn process will already alive but the mysql_recv process dead
why we don't close the mysql_conn process here since it no use!!
it not restart no use
mysql:fetch(poolid, <<"call demo.test_return_result_set();">>).
{error,{mysql_result,[],[],0,
<<"#0A000PROCEDURE demo.test_return_result_set can't return a result set in the given context">>}}
CLIENT_MULTI_RESULTS and CLIENT_MULTI_STATEMENTS are not supported?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.