每当有任何请求时,此查询命令在后端运行这么多次:
SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
Run Code Online (Sandbox Code Playgroud)
为什么Rails不只是运行一次?
另外,为什么它将wait_timeout设置为2147483,它是如此巨大,如此多的时间,它只是让我的服务器关闭,因为在睡眠模式下有这么多查询超过100小时.
我不得不将其更新为180秒.
default: &default
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
socket: /var/run/mysqld/mysqld.sock
wait_timeout: 180
Run Code Online (Sandbox Code Playgroud)
我做错了什么.我不知道.
为什么将wait_timeout设置为2147483
这是一个问题与mysql2适配器!
mysql2_adapter使用相同的wait_timeout,但是直接将它传递给mysql,默认为更大的2592000 !!(现在默认为2147483)
# increase timeout so mysql server doesn't disconnect us
wait_timeout = @config[:wait_timeout]
wait_timeout = 2147483 unless wait_timeout.is_a?(Fixnum)
variable_assignments << "@@wait_timeout = #{wait_timeout}"
execute("SET #{variable_assignments.join(', ')}", :skip_logging)
Run Code Online (Sandbox Code Playgroud)