1

ActiveRecord 允许您配置数据库 read_timeout 和 write_timeout 值,例如:

production:
  adapter: mysql
  encoding: utf8
  database: mydb
  pool: 5
  username: myuser
  password: mypass
  host: myhost
  write_timeout: 2
  read_timeout: 10

read_timeout 和 write_timeout 是 ActiveRecord 独有的,还是 mysql 规范的一部分?我知道 mysql 有innodb_lock_wait_timeout的概念,但我不认为这与查询超时相同。

谢谢!

4

1 回答 1

-1

我从未使用过 mysql gem。但我认为您可以像这样看到 ActiveRecord 使用的 mysql 变量。

> ActiveRecord::Base.connection.execute('show variables like "%timeout%"').to_a
=> [["connect_timeout", "10"],
 ["delayed_insert_timeout", "300"],
 ["innodb_flush_log_at_timeout", "1"],
 ["innodb_lock_wait_timeout", "50"],
 ["innodb_rollback_on_timeout", "OFF"],
 ["interactive_timeout", "28800"],
 ["lock_wait_timeout", "31536000"],
 ["net_read_timeout", "30"],
 ["net_write_timeout", "60"],
 ["rpl_stop_slave_timeout", "31536000"],
 ["slave_net_timeout", "3600"],
 ["wait_timeout", "2147483"]]
于 2014-09-13T11:57:32.253 回答