Som*_*Guy 10 database postgresql activerecord ruby-on-rails-4
在database.yml中,是以秒或毫秒为单位的超时?具体是什么,整个数据库连接的超时包括连接的等待时间或其他什么?
超时以毫秒为单位.这是rails app等待数据库响应的整个时间.好的做法是在此文件中添加重新连接选项,然后应用程序将尝试重新连接到服务器,然后在连接丢失的情况下放弃.
在放弃和引发超时错误之前阻塞和等待连接的秒数(默认为 5 秒)。
wait_timeout: 900 # 15 minutes.
timeout: 5000 # 5 seconds.
Run Code Online (Sandbox Code Playgroud)
MYSQL 文档说:
1. wait_timeout : The number of seconds the server waits for activity on a
noninteractive connection before closing it. The default value is 28800.
2. connect_timeout : The number of seconds that the mysqld server waits for
a connect packet before responding with Bad handshake. The default value is 10 seconds.
Run Code Online (Sandbox Code Playgroud)
connect_timeout mysql 映射到data_base.yml rails 中定义的超时,默认设置为 5 秒。