A platform for community discussion. Free, open, simple.
DEV: Use MiniSql ActiveRecordPostgres adapter (#15767)
David Taylor3f6c2f82d00d
diff --git a/Gemfile.lock b/Gemfile.lockindex 068c2ce7004..a4c43815041 100644--- a/Gemfile.lock+++ b/Gemfile.lock@@ -236,7 +236,7 @@ GEMlibv8-node (~> 16.10.0.0)mini_scheduler (0.13.0)sidekiq (>= 4.2.3)- mini_sql (1.1.3)+ mini_sql (1.3.0)mini_suffix (0.3.3)ffi (~> 1.9)minitest (5.15.0)diff --git a/lib/freedom_patches/schema_cache_concurrency.rb b/lib/freedom_patches/schema_cache_concurrency.rbdeleted file mode 100644index b805c665269..00000000000--- a/lib/freedom_patches/schema_cache_concurrency.rb+++ /dev/null@@ -1,27 +0,0 @@-# frozen_string_literal: true-#-# Rails has a circular dependency in SchemaCache.-# In certain situation SchemaCache can carry a @connection-# from a different thread. This causes potential concurrency bugs-# in Sidekiq.-#-# This patches it so it is less flexible (theoretically) but always bound to the current connection--# This patch needs to be reviewed in future versions of Rails.-# We should consider upstreaming this optionally.--module ActiveRecord- module ConnectionAdapters- class SchemaCache-- def connection=(connection)- # AbstractPool get_schema_cache does schema_cache.connection = connection- Thread.current["schema_cached_connection"] = connection- end-- def connection- Thread.current["schema_cached_connection"]- end- end- end-enddiff --git a/lib/mini_sql_multisite_connection.rb b/lib/mini_sql_multisite_connection.rbindex a4feb1a8706..26ad1d50263 100644--- a/lib/mini_sql_multisite_connection.rb+++ b/lib/mini_sql_multisite_connection.rb@@ -1,6 +1,6 @@# frozen_string_literal: true-class MiniSqlMultisiteConnection < MiniSql::Postgres::Connection+class MiniSqlMultisiteConnection < MiniSql::ActiveRecordPostgres::Connectionclass CustomBuilder < MiniSql::Builder@@ -78,8 +78,8 @@ class MiniSqlMultisiteConnection < MiniSql::Postgres::Connection# we need a tiny adapter here so we always run against the# correct multisite connection- def raw_connection- ActiveRecord::Base.connection.raw_connection+ def active_record_connection+ ActiveRecord::Base.connectionend# make for a multisite friendly prepared statement cache