-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connection issues #289
Comments
void DBQuery::start(std::shared_ptr<boost::mysql::connection_pool> pool) {
pool->async_get_connection(
std::chrono::seconds(0),
[this, self = shared_from_this()](boost::system::error_code ec, boost::mysql::pooled_connection connection) {
if (ec) {
onFail(ec, "connect");
return;
}
_conn = std::move(connection);
_conn->async_execute(_sql, _results, _errorInfo,
[this, self = shared_from_this()](boost::system::error_code ec) {
if (ec) {
onFail(ec, "query");
return;
}
LOG_DEBUG(gLogger, "DBService::query type:{} sn:{} sql:{}", _type, _sn, _sql);
_callback(true, self);
});
});
}
void DBQuery::onFail(boost::system::error_code ec, std::string_view prefix) {
LOG_ERROR(gLogger, "DBService::{} type:{} sn:{} sql:{} code:{} error:{}", prefix, _type, _sn, _sql, ec.value(),
ec.message());
_callback(false, shared_from_this());
} 24-06-24 20:50:25 29400 error DBService::query type:2 sn:1125899906850706 sql:SELECT |
What's your server's |
I use SHOW STATUS LIKE 'Threads connected'; At the beginning, it was 1000, but after a while, it will become 1 |
After how much time did the connections die? |
They are all on the same machine and disappear in about a minute |
I think I found the problem. The wait_time setting is too short and only lasts for 100 seconds. |
If it is for this reason, why do disconnected connections still exist in the connection pool? Or why did I receive a disconnected connection? |
Do you mean Connections in the pool don't have a way of detecting that the connection was closed by the server, at least not immediately. Unused connections actively check for liveliness by using In your case, the server closes the connection but the pool doesn't have a way to detect it. When you get a connection, your operation fails and the connection gets returned to the pool. The pool tries to reset the connection and fails (it's closed), and then reconnects it. If you need to set |
If it defaults to 8 hours, there won't be any problem, right. |
I saw the code comments, and the unused connection will ping once every hour. Due to my previous setting of only 100sec, the connection was closed and not detected. Then, I used this connection again, resulting in network reconnection issues. |
Great. I've opened an issue to state this more clearly in the docs. I'll be closing this one. |
Thank you very much. |
I initialized the default minimum of 1000 connections, but after a while, the connections were released. When my SQL request arrived, I reconnected. However, on the Windows platform, I encountered a large number of 10053 errors, which caused the SQL request to be unable to be executed. What should I do?
The text was updated successfully, but these errors were encountered: