Skip to content

Commit

Permalink
Fixed issue zammad#1405 - Scheduler not running because of Bad file d…
Browse files Browse the repository at this point in the history
…escriptor in PGConsumeInput().
  • Loading branch information
martini committed Sep 25, 2017
1 parent 18edd73 commit 1ba32b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 0 additions & 2 deletions app/models/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ def self.threads
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
Expand Down
6 changes: 6 additions & 0 deletions script/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

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|
Expand Down

0 comments on commit 1ba32b1

Please sign in to comment.