From aacb930094936b9b66119206aada607b5f67ae1c Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 16 Feb 2015 13:41:46 +0100 Subject: [PATCH] Close database connection for thread after thread is finished. --- app/models/scheduler.rb | 1 + lib/import/otrs2.rb | 1 + lib/sessions.rb | 1 + 3 files changed, 3 insertions(+) diff --git a/app/models/scheduler.rb b/app/models/scheduler.rb index a59b986c6..b7c05350c 100644 --- a/app/models/scheduler.rb +++ b/app/models/scheduler.rb @@ -57,6 +57,7 @@ class Scheduler < ApplicationModel job.pid = '' job.save logger.info " ...stopped thread for '#{job.method}'" + ActiveRecord::Base.connection.close } end diff --git a/lib/import/otrs2.rb b/lib/import/otrs2.rb index f653ed7de..f88497f8f 100644 --- a/lib/import/otrs2.rb +++ b/lib/import/otrs2.rb @@ -377,6 +377,7 @@ module Import::OTRS2 end _ticket_result(records, locks) end + ActiveRecord::Base.connection.close } } (1..thread_count).each {|thread| diff --git a/lib/sessions.rb b/lib/sessions.rb index 0962312d9..64bc64c37 100644 --- a/lib/sessions.rb +++ b/lib/sessions.rb @@ -498,6 +498,7 @@ returns thread_client(client_id) @@client_threads[client_id] = nil puts "close client (#{client_id}) thread" + ActiveRecord::Base.connection.close } sleep 0.5 end