mysqlpp 连接方法超时 - 我怎样才能控制它?
我试图控制连接方法超时,但我没有找到合适的方法。
需要明确的是,我不是在谈论空闲连接超时(ConnectTimeoutOption)。
我需要处理的场景是数据库消失了,我的服务器必须处理这个问题。我当前的处理方式是对服务器执行 ping 操作,如果我发现 ping 失败,我将暂停查询 100 秒。之后我尝试重新建立连接。问题是,如果数据库仍然死掉,那么 connect 方法需要大约 20 秒才能应答(可以通过拉网线来模拟),这对我来说太难了。
I'm trying to control the connect method timeout, but I didn't find the appropriate mean.
Just to be clear, I'm not talking about the Idle connection timeout(ConnectTimeoutOption).
The scenario I need to deal with is a database gone away, and my server has to cope with that. My current handling of things is that I'm pinging the server, and If I notice that the ping failed, I'm suspending the queries for 100 seconds. After that I'm trying to reestablish the connection. The problem is that if the database is still dead, than the connect method takes about 20 seconds to answer (can be simulated by just pulling the network cable), which is way too much for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该适合你
This should work for you
试试这个。
try this out.