Rails database.yml中哪些单位超时?

时间:2015-03-21 05:44:50

标签: database postgresql ruby-on-rails-4 activerecord

在database.yml中,是以秒或毫秒为单位的超时?具体是什么,整个数据库连接的超时,包括连接的等待时间或其他什么?

3 个答案:

答案 0 :(得分:8)

超时以毫秒为单位。这是rails app等待数据库响应的整个时间。好的做法是在此文件中添加重新连接选项,然后应用程序将尝试重新连接到服务器,然后在连接丢失的情况下放弃。

答案 1 :(得分:4)

在放弃和引发超时错误之前阻塞并等待连接的秒数(默认为5秒)。

wait_timeout: 900 # 15 minutes.
timeout: 5000 # 5 seconds.

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.

connect_timeout mysql映射到 data_base.yml rails中定义的超时,默认设置为5秒。

答案 2 :(得分:0)

如果使用checkout_timeout,则以秒为单位。