From: Lucas Di Pentima Date: Thu, 23 Jul 2020 20:54:32 +0000 (-0300) Subject: 16470: Changes the way of setting the callback that sets the DB timezone. X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/22589907a1c0017965eee98a9839285a1402788b 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 --- 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