On 07/01/2010 03:12 AM, Markus Hoenicka wrote:
Vikram Ambrose noel.ambr...@gmail.com was heard to say:
Is there a way of having the mysql driver, reconnect and then complete
the query without erroring out, in the case of driver/server timeout?
This way I do not lose my query to a timeout or need to have some sort
of global command buffer that the callback would use to re-execute the
failed query.
Hi,
does the MySQL API provide enough information to tell from a failure
of mysql_query that the connection has stalled? I've found a log entry
in cvs which added a timeout option to the driver, so with that in
place and a useful error message from libmysqlclient I'd say it's
doable. We'd just have to loop over a limited number of retries,
trying to reconnect each time before resending the query.
There is indeed enough information to find this scenario. Here is a very
simple callback I use at the moment:
void DB_error_callback(dbi_conn conn, void *udata){
int rv;
const char *errormsg = NULL;
rv = dbi_conn_error(DB_conn,errormsg);
if(strstr(errormsg,gone away)){
rv = dbi_conn_connect(DB_conn);
if(rv){
printf(ERROR: DB_error_callback: Tried to reconnect -
failed\n);
}else {
printf(ERROR: DB_error_callback: Reconnected\n);
}
}
}
--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users