Redmine 中出现间歇性 500 内部服务器错误



某些用户在登录和尝试浏览某些页面时,或者当服务器空闲一段时间或访问我的控制器页面时,会收到 500 错误。

发生 500 错误的生产日志如下:

Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.3ms)
ActiveRecord::StatementInvalid (Mysql2::Error: MySQL server has gone away: SELECT 
MAX(`settings`.`updated_on`) FROM `settings`):
app/models/setting.rb:231:in `check_cache'
app/controllers/application_controller.rb:90:in `user_setup'
Started GET "/" for 127.0.0.1 at 2019-12-29 08:52:50 +0000
Processing by MyController#page as HTML
Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.2ms)
ActiveRecord::StatementInvalid (Mysql2::Error: MySQL server has gone away: SELECT MAX(`settings`.`updated_on`) FROM `settings`):
app/models/setting.rb:231:in `check_cache'
app/controllers/application_controller.rb:90:in `user_setup'
Started GET "/" for 127.0.0.1 at 2019-12-29 08:52:56 +0000
Mysql2::Error (Can't connect to MySQL server on 'rds-prod-db-xxxxx.c3uzu7me4rud.us-east-1.rds.amazonaws.com' (111)):
Completed 500 Internal Server Error in 134ms (ActiveRecord: 69.2ms)

第二个错误:

ActiveRecord::StatementInvalid (Mysql2::Error: Deadlock found when trying to get lock; try restarting transaction: UPDATE `issues` SET `issues`.`done_ratio` = 90, `issues`.`updated_on` = '2020-01-20 08:22:21', `issues`.`lock_version` = 49 WHERE `issues`.`id` = 328453 AND `issues`.`lock_version` = 48):
app/models/issue.rb:210:in `create_or_update'
app/models/issue.rb:1716:in `recalculate_attributes_for'
app/models/issue.rb:1666:in `update_parent_attributes'
app/models/issue.rb:210:in `create_or_update'
app/controllers/issues_controller.rb:558:in `block in save_issue_with_child_records'
app/controllers/issues_controller.rb:546:in `save_issue_with_child_records'
app/controllers/issues_controller.rb:168:in `update'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'

第三个错误:

Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.2ms)
ActiveRecord::StatementInvalid (Mysql2::Error: MySQL server has gone away: UPDATE `tokens` SET `tokens`.`updated_on` = '2020-02-02 09:07:22' WHERE `tokens`.`user_id` = 289 AND `tokens`.`value` = 'a30e44e2ac37c8ba31eb383a409509c0d5fbb8be' AND `tokens`.`action` = 'session' AND (created_on > '2020-02-01 09:07:22') AND (updated_on > '2020-02-01 09:07:22')):
app/models/user.rb:445:in `verify_session_token'
app/controllers/application_controller.rb:77:in `session_expired?'
app/controllers/application_controller.rb:67:in `session_expiration'
Started GET "/" for 127.0.0.1 at 2020-02-02 09:07:25 +0000

我在Redmine论坛的早期主题中看到了一个几乎相同的问题,但尚未找到解决方案。 信息: 环境:

Redmine version                3.4.4.stable
Ruby version                   2.2.2-p95 (2015-04-13) [x86_64-linux]
Rails version                  4.2.8
Environment                    production
Database adapter               Mysql2
SCM:
Subversion                     1.7.14
Git                            1.8.3.1
Filesystem                     
Redmine plugins:
redmine_query_share            2.1.0
redmine_agile                  1.4.5
sidebar_hide                   0.0.7

红宝石服务器:彪马 Puma_worker_killer配置:

PumaWorkerKiller.config do |config|
config.ram           = 4096 # mb
config.frequency     = 60   # seconds
config.percent_usage = 0.90
config.rolling_restart_frequency = 10 * 3600 # 12 hours in seconds, or 12.hours if using Rails
config.reaper_status_logs = true # setting this to false will not log lines like:
# PumaWorkerKiller: Consuming 54.34765625 mb with master and 2 workers.
config.pre_term = -> (worker) { puts "Worker #{worker.inspect} being killed" 
Thread: 4-16
}
end

我对 Ruby on rails 和 redmine 很陌生。任何帮助将不胜感激。 谢谢。

我过去遇到过这种问题,并通过更新MySQL配置(在my.cnf中(找到了解决方案。 在配置文件中添加一行,如下所示:

[mysqld] 
max_allowed_packet=100M

通常,您不需要重新启动MySQL服务器。

最新更新