From 22589907a1c0017965eee98a9839285a1402788b Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Thu, 23 Jul 2020 17:54:32 -0300 Subject: [PATCH] 16470: Changes the way of setting the callback that sets the DB timezone. This avoids intermittent freezes when running tests. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- services/api/config/initializers/time_zone.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/api/config/initializers/time_zone.rb b/services/api/config/initializers/time_zone.rb index cedd8f3e4a..26681d613f 100644 --- a/services/api/config/initializers/time_zone.rb +++ b/services/api/config/initializers/time_zone.rb @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: AGPL-3.0 -ActiveRecord::Base.connection.class.set_callback :checkout, :after do +ActiveRecord::ConnectionAdapters::AbstractAdapter.set_callback :checkout, :before, ->(conn) do # If the database connection is in a time zone other than UTC, # "timestamp" values don't behave as desired. # @@ -11,5 +11,5 @@ ActiveRecord::Base.connection.class.set_callback :checkout, :after do # before now()), but false in time zone -0100 (now() returns an # earlier clock time, and its time zone is dropped when comparing to # a "timestamp without time zone"). - raw_connection.sync_exec("SET TIME ZONE 'UTC'") + conn.execute("SET TIME ZONE 'UTC'") end -- 2.30.2