“MySQL server has gone away” with Ruby on Rails

后端 未结 11 1313
后悔当初
后悔当初 2020-12-12 19:09

After our Ruby on Rails application has run for a while, it starts throwing 500s with \"MySQL server has gone away\". Often this happens overnight. It\'s started doing this

11条回答
  •  猫巷女王i
    2020-12-12 20:00

    Ruby on Rails 2.3 has a reconnect option for your database connection:

    production:
      # Your settings
      reconnect: true
    

    See:

    • Ruby on Rails 2.3 Release Notes, sub section 4.8 Reconnecting MySQL Connections.

    • MySQL auto-reconnect revisited

    Good luck!

提交回复
热议问题