Re: [Cppcms-users] How to reconnect to MySQL
Brought to you by:
artyom-beilis
|
From: Artyom B. <art...@ya...> - 2011-12-05 20:11:02
|
Hello,
I had checked it and yes indeed, there is a problem.
The opt_reconnect does not work as prepared statements do not survive connection lost.
It works with @use_prepared=off and opt_reconnect=1 but of course it has performance
penalty as you loose all advantages of CppDB prepared statements caching.
If the connection is lost due to timeout then probably you can change @pool_max_idle
to smaller value (default is 600 i.e. 10 minutes)
>
> But it didn't work. How should I do? Catch exception
> and call cppdb::connections_manager::gc() ?
>
Currently this is only option that works.
Also notice that you need to call it **after** connection is closed:
try {
cppdb::session sql(...)
}catch(cppdb::cppdb_error const &) {
cppdb::connections_manager::instance().gc();
throw;
}
I'll look on it deeply ASAP, but it is not something simple to fix.
I had opened a ticket:
https://sourceforge.net/tracker/?func=detail&aid=3451653&group_id=209965&atid=1011835
Artyom Beilis
--------------
CppCMS - C++ Web Framework: http://cppcms.sf.net/
CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/
>________________________________
> From: 陈抒 <csf...@gm...>
>
>
>Hello,
> My web site's DB connection broke because of timeout. My web site is developed in China,but MySQL server is running in the USA. I got one error log:
>2011-12-05 15:43:02 GMT; cppcms, error: Caught exception [cppdb::mysql::Lost connection to MySQL server during query]
> (http_context.cpp:150)
>
>
> I have used reconnect property already:
> stringstream stream;
> stream<<"mysql:host="<<config.mysql_ip<<";database="<<config.mysql_db_name<<";user="<<config.mysql_user<<";password="<<config.mysql_password<<";@pool_size=20;set_charset_name=utf8;opt_reconnect=1";
>
>
>
>陈抒
>Best regards
>http://blog.csdn.net/sheismylife
>
>------------------------------------------------------------------------------
>All the data continuously generated in your IT infrastructure
>contains a definitive record of customers, application performance,
>security threats, fraudulent activity, and more. Splunk takes this
>data and makes sense of it. IT sense. And common sense.
>http://p.sf.net/sfu/splunk-novd2d
>_______________________________________________
>Cppcms-users mailing list
>Cpp...@li...
>https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
>
>
|