X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2b8f39b5067103d60f7bc43d26cb2f59126b2a42..5bf138526df5d0dd36888c019e2f16403329d5a1:/services/api/lib/sweep_trashed_objects.rb diff --git a/services/api/lib/sweep_trashed_objects.rb b/services/api/lib/sweep_trashed_objects.rb index bedbd68a44..c09896567f 100644 --- a/services/api/lib/sweep_trashed_objects.rb +++ b/services/api/lib/sweep_trashed_objects.rb @@ -55,8 +55,8 @@ module SweepTrashedObjects end def self.sweep_if_stale - return if Rails.configuration.trash_sweep_interval <= 0 - exp = Rails.configuration.trash_sweep_interval.seconds + return if Rails.configuration.Collections.TrashSweepInterval <= 0 + exp = Rails.configuration.Collections.TrashSweepInterval.seconds need = false Rails.cache.fetch('SweepTrashedObjects', expires_in: exp) do need = true @@ -69,7 +69,12 @@ module SweepTrashedObjects rescue => e Rails.logger.error "#{e.class}: #{e}\n#{e.backtrace.join("\n\t")}" ensure - ActiveRecord::Base.connection.close + # Rails 5.1+ makes test threads share a database connection, so we can't + # close a connection shared with other threads. + # https://github.com/rails/rails/commit/deba47799ff905f778e0c98a015789a1327d5087 + if Rails.env != "test" + ActiveRecord::Base.connection.close + end end end end