From 1ba32b1a418115a4cf006b63af4696152eab9968 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 25 Sep 2017 23:47:37 +0200 Subject: [PATCH] Fixed issue #1405 - Scheduler not running because of Bad file descriptor in PGConsumeInput(). --- app/models/scheduler.rb | 2 -- script/scheduler.rb | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/scheduler.rb b/app/models/scheduler.rb index 844fe5f84..0c5db3386 100644 --- a/app/models/scheduler.rb +++ b/app/models/scheduler.rb @@ -12,10 +12,8 @@ class Scheduler < ApplicationModel Thread.abort_on_exception = true # reconnect in case db connection is lost - # See issue #1080 begin ActiveRecord::Base.connection.reconnect! - rescue PG::UnableToSend => e # rubocop:disable Lint/HandleExceptions rescue => e logger.error "Can't reconnect to database #{e.inspect}" end diff --git a/script/scheduler.rb b/script/scheduler.rb index 5be7db8c3..fdd2e8523 100755 --- a/script/scheduler.rb +++ b/script/scheduler.rb @@ -16,6 +16,12 @@ require 'daemons' def before_fork + # clear all connections before for, reconnect later ActiveRecord::Base.connection.reconnect! + # issue #1405 - Scheduler not running because of Bad file descriptor in PGConsumeInput() + # https://github.com/zammad/zammad/issues/1405 + # see also https://bitbucket.org/ged/ruby-pg/issues/260/frequent-crashes-with-multithreading + ActiveRecord::Base.clear_all_connections! + # remember open file handles @files_to_reopen = [] ObjectSpace.each_object(File) do |file|