A platform for community discussion. Free, open, simple.
DEV: Fix `PG::ReadOnlySqlTransaction` flakes (#40507)
Jarek Radosz3d285625f6d3
diff --git a/app/models/report.rb b/app/models/report.rbindex 5b83fc9617e..df1b061a032 100644--- a/app/models/report.rb+++ b/app/models/report.rb@@ -254,8 +254,9 @@ class Reportdef self.wrap_slow_query(timeout = 20_000)ActiveRecord::Base.connection.transaction do- # Allows only read only transactions- DB.exec "SET TRANSACTION READ ONLY"+ # Allows only read only transactions. Skipped in tests, where threads+ # share one connection and read-only would break concurrent writes.+ DB.exec "SET TRANSACTION READ ONLY" if !Rails.env.test?# Set a statement timeout so we can't tie up the serverDB.exec "SET LOCAL statement_timeout = #{timeout}"yield