我在我的OS X 10.9.5上使用MySQL Workbench 6.3管理多个云数据库(托管在Rackspace上),我得到以下问题:
当不活动5分钟时,会发生以下问题:
所以基本上连接已经消失了.
这真的很烦人,因为它只在不活动5分钟后发生.因此,我需要关闭连接并每次重新打开它.
我也试过这个:MySQL Workbench:如何保持连接活着,这没有改变任何东西.在我的Workbench Preferences选项卡中,我有以下设置:
请注意,此问题恰好在不活动5分钟后发生!如果我在4'59分钟的间隔内运行两个查询,它的工作完全正常.同样在Workbench上连接到同一数据库的同事也没有这个问题.
有人有解决方案吗?
我有一个托管我的网站的服务器几乎没有流量.
一些人(<20)每天进入该网站,一些RSS阅读器订阅了我们推出的一些提要.
几乎每天晚上,一个RSS阅读器都会在半夜打电话给我们,并且由于连接中的超时而导致网站无法连接到SQL Server.细节非常奇怪,所以我正在寻找一些可能出现问题的帮助,因为我不知道从哪里开始寻找.
我们在Windows Server 2008上使用ASP.Net MVC,实体框架和SQL Server 2008.这台机器是我们从一个不完全顶级的提供商那里获得的专用盒子,所以事情可能是非最佳配置,或者谁知道什么其他.
盒子也很小,只有1Gb的RAM,但它应该承担我们现在的那种负载......
我正在复制下面的完整调用堆栈,但首先,我们知道的一些事情:
更新:我们按照建议添加了一个分析器,在我们遇到新的异常之前花了很长时间.这是我们所知道的新内容:
所以,简而言之,我对这一点完全无能为力.我无法找到那些快速连续运行的数百个查询的原因,但我相信这些问题必须与问题有关.
我也不知道如何诊断连接问题...
或者如果Profiler跟踪可能会丢失一些根据IIS进行的查询...
有任何想法吗?
这是例外信息:
System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
System.Data.EntityException: The underlying provider failed on Open. ---> System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior …Run Code Online (Sandbox Code Playgroud) 我使用Elasticsearch-1.1.0来索引推文.索引过程没问题.然后我升级了版本.现在我使用Elasticsearch-1.3.2,我随机收到这条消息:
Exception happened: Error raised when there was an exception while talking to ES.
ConnectionError(HTTPConnectionPool(host='127.0.0.1', port=8001): Read timed out. (read timeout=10)) caused by: ReadTimeoutError(HTTPConnectionPool(host='127.0.0.1', port=8001): Read timed out. (read timeout=10)).
Run Code Online (Sandbox Code Playgroud)
随机快照:
Happened --33s-- Happened --27s-- Happened --22s-- Happened --10s-- Happened --39s-- Happened --25s-- Happened --36s-- Happened --38s-- Happened --19s-- Happened --09s-- Happened --33s-- Happened --16s-- Happened
--XXs-- = after XX seconds
Run Code Online (Sandbox Code Playgroud)
有人可以指出如何解决Read timed out问题吗?
非常感谢你.
timeout timeoutexception connection-timeout executiontimeout elasticsearch
我有一个多线程Windows服务,我用VS 2010(.NET 4.0)开发,可以有几个到几十个线程,每个线程通过Internet从慢速服务器检索数据,然后使用本地数据库记录这个数据(因此进程受Internet限制,而不是LAN或CPU绑定).
有一些规律性,我从几个线程同时得到以下错误的洪水/乱舞/爆发:
System.Data.SqlClient.SqlException(0x80131904):超时已过期.操作完成之前经过的超时时间或服务器没有响应.
此错误的调用堆栈通常是:
在System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
在System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
在System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory)
在System.Data.SqlClient.SqlConnection.Open()
我没有在连接字符串中指定连接超时,并且此数据库中还有其他应用程序和进程.有没有人遇到过这种行为,如果有的话,采取了哪些措施来防止它?
我的数据访问层中最常用的方法如下所示,我所有其他DAL方法都遵循相同的方法:
using (SqlConnection con = new SqlConnection(GetConnectionString()))
using (SqlCommand cmd = new SqlCommand("AddGdsMonitorLogEntry", con))
{
cmd.CommandType = CommandType.StoredProcedure;
/* setting cmd.Parameters [snipped] */
// We have been getting some timeouts writing to the log; wait a little longer than the default.
cmd.CommandTimeout *= 4;
con.Open();
cmd.ExecuteNonQuery();
}
Run Code Online (Sandbox Code Playgroud)
非常感谢!
编辑
鉴于在镜像环境中发生这种情况的评论,我确实应该提到有问题的数据库是镜像的.它在SSMS中标记为"Principal,Synchronized","高安全性,无自动故障转移(同步)"模式.
编辑5/26/11
我在SQL Server日志中看不到任何问题.(我无法访问该服务器上的Windows事件查看器,但我已经要求有人找我.)
我有一个返回TimeOut的Sql Alchemy应用程序:
TimeoutError:达到大小为5的QueuePool限制溢出10,连接超时,超时30
我在另一篇文章中读到,当我不关闭会话时会发生这种情况,但我不知道这是否适用于我的代码:
我在init.py中连接到数据库:
from .dbmodels import (
DBSession,
Base,
engine = create_engine("mysql://" + loadConfigVar("user") + ":" + loadConfigVar("password") + "@" + loadConfigVar("host") + "/" + loadConfigVar("schema"))
#Sets the engine to the session and the Base model class
DBSession.configure(bind=engine)
Base.metadata.bind = engine
Run Code Online (Sandbox Code Playgroud)
然后在另一个python文件中我收集了两个函数中的一些数据,但是使用了我在init.py中初始化的DBSession:
from .dbmodels import DBSession
from .dbmodels import resourcestatsModel
def getFeaturedGroups(max = 1):
try:
#Get the number of download per resource
transaction.commit()
rescount = DBSession.connection().execute("select resource_id,count(resource_id) as total FROM resourcestats")
#Move the data to an array
resources …Run Code Online (Sandbox Code Playgroud) 每当我有一个使用ActiveRecord的应用程序时,我得到这个ConnectionTimeoutError - 但总是在一段未知的时间之后
ActiveRecord::ConnectionTimeoutError (could not obtain a database connection within 5 seconds. The max pool size is currently 30; consider increasing it.):
Run Code Online (Sandbox Code Playgroud)
它之前设置为5,我们已经增加了它,并且它无法同时使用30个连接.我们使用ActiveRecord的唯一方法是我们的会话存储.
我们的database.yml文件如下所示:
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 30
timeout: 5000
Run Code Online (Sandbox Code Playgroud)
(测试和生产设置相同)
我一直在谷歌搜索这个事件,刚刚发现这个帖子:
https://groups.google.com/forum/#!msg/copenhagen-ruby-user-group/GEHgi_WudmM/gnCiwWqmVfMJ
哪个提到ActiveRecord一旦完成就不会检查连接回池?真的吗?我是否需要手动管理连接?
我很感激任何建议!!
编辑我应该提一下我正在运行Rails 3.1.3
activerecord database-connection ruby-on-rails connection-timeout ruby-on-rails-3.1
我已经初始化了我的restTemplate,如下所示:
HttpClient httpClient = HttpClientBuilder.create().build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
requestFactory.setConnectTimeout(1000);
requestFactory.setReadTimeout(1000);
restTemplate = new RestTemplate(requestFactory);
Run Code Online (Sandbox Code Playgroud)
而我这样称呼它:
restTemplate.getForEntity(someString, String.class, SomeHashmapWithURLParameters)
Run Code Online (Sandbox Code Playgroud)
我如何处理这两个超时?我假设会抛出一个异常?如果是这样,我可以捕获哪个特定的异常,以便专门处理只是超时.我以不同的方式处理其他异常.
在我的应用程序中,我连接到服务器以验证用户.这是代码:
try {
Properties prop = new Properties();
prop.put("mail.smtp.starttls.enable","true");
prop.put("mail.smtp.auth", "true");
prop.put("mail.smtp.connectiontimeout", 1000);
Session session = Session.getInstance(prop, null);
Transport transport = session.getTransport("smtp");
transport.connect("mion.elka.pw.edu.pl", 587, registerLog, registerPass);
transport.close();
return true;
} catch (NoSuchProviderException ex) {
Logger.getLogger(RegisterController.class.getName()).log(Level.SEVERE, null, ex);
return false;
} catch(AuthenticationFailedException ex) {
Logger.getLogger(RegisterController.class.getName()).log(Level.SEVERE, null, ex);
return false;
} catch (MessagingException ex) {
Logger.getLogger(RegisterController.class.getName()).log(Level.SEVERE, null, ex);
return false;
}
Run Code Online (Sandbox Code Playgroud)
我将连接超时设置为1000毫秒= 1秒,但它被忽略.当我调试并设置错误的用户名和密码时,我抓住了
javax.mail.MessagingException: java.net.SocketTimeoutException: Read timed out
Run Code Online (Sandbox Code Playgroud)
不是在1000毫秒之后,而是在5000*60毫秒= 5分钟之后
怎么了 ?我怎样才能减少时间?
$url = 'http://a.url/i-know-is-down';
//ini_set('default_socket_timeout', 5);
$ctx = stream_context_create(array(
'http' => array(
'timeout' => 5,
'ignore_errors' => true
)
)
);
$start = microtime(true);
$content = @file_get_contents($url, false, $ctx);
$end = microtime(true);
echo $end - $start, "\n";
Run Code Online (Sandbox Code Playgroud)
我得到的反应一般是21.232 segs,不应该是大约5秒???
取消注释ini_set行根本没有帮助.
timeout ×5
java ×2
activerecord ×1
cloudflare ×1
connection ×1
database ×1
jakarta-mail ×1
mysql ×1
php ×1
python ×1
resttemplate ×1
session ×1
spring-boot ×1
sql-server ×1
sqlalchemy ×1
zope ×1