1

私は dashing.io を使用しており、rufus スケジューラを使用して mysql データベースからデータを取得し、それらをプッシュしたいと考えています。

1 つの .rb ジョブ ファイルで接続の終了をテストするための次のコードがあります。

require 'rubygems'
require 'mysql2'
SCHEDULER.every '12h', :first_in => 0 do |job|
  begin
    db = Mysql2::Client.new(:host => "localhost", :username => "root", :password => "rainer-zufall", :port => 2971, :database => "test" )
    open_connections = db.query("show status like 'Connections';")
    open_connections.each do |row|
      puts "connections: #{row}"
    end
  rescue

  ensure
    db.close
  end
end

データベース接続は閉じません。接続カウンターは引き続き増加し、すぐに mysql-server から max_connections に到達したことを示すエラーが発生します。

誰でも助けることができますか?

4

0 に答える 0