16470: Changes the way of setting the callback that sets the DB timezone.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Thu, 23 Jul 2020 20:54:32 +0000 (17:54 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Fri, 7 Aug 2020 14:54:35 +0000 (11:54 -0300)
This avoids intermittent freezes when running tests.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

services/api/config/initializers/time_zone.rb

index cedd8f3e4a325b4e438febdc7d8cc9a7367c1a56..26681d613fa60b1daaa8857bdf4bebe3bd082096 100644 (file)
@@ -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