Hello.
There is a database on a dedicated server to which Linux clients connect remotely and work with it through a call to stored procedures. Clients use the mysql ++ version 3.2.2 library to work with the database, connecting to the network using pppoe.
Work from the database on the client (connection, calls to stored procedures, processing of query results) is performed in a separate thread. Stored procedure call code (C ++):
try { mysqlpp::Query sqlrequest = mConn.query(); sqlrequest << requestS; sqlrequest.exec(); return (true); } catch (const mysqlpp::BadQuery &e) { mlog << "SQL-query error[" << e.errnum() << "]: " << e.what() << mlog.endl; this->disconnect(); } catch (const mysqlpp::Exception &ex) { mlog << "SQL-request error: " << ex.what() << mlog.endl; this->disconnect(); } catch(...) { mlog << "Catched exception in " << __FUNCTION__ << "(): " << mlog.endl; } return (false); The problem is this: if the connection to the network is broken when you call sqlrequest.exec (), then the thread that performed the call on the client is blocked without exception return or an error code. The blocking time is not constant, the function may return exception after 5 minutes, or it may not return even after 30 (a record of 2 hours, then it’s tired of waiting).
When connecting, I set up timeouts, but in this situation they do not affect anything.
mConn.set_option(new mysqlpp::ReconnectOption(true)); mConn.set_option(new mysqlpp::ReadTimeoutOption(5)); mConn.set_option(new mysqlpp::WriteTimeoutOption(5)); mConn.set_option(new mysqlpp::ConnectTimeoutOption(10)); isConnected = mConn.connect(mDatabaseName.c_str(), mDatabaseAddr.c_str(), mDatabaseUser.c_str(), mDatabasePass.c_str(), mDatabasePort); If during the blocking of the flow, the connection to the network is restored again, the return from the function still does not occur and the flow remains blocked.
Tell me, please, how to correct this behavior?