DEV: Use MiniSql ActiveRecordPostgres adapter (#15767)

This adapter ensures that MiniSql locks the ActiveRecord mutex before using the raw PG connection. This ensures that multiple threads will not attempt to use the same connection simultaneously.

This commit also removes the schema_cache_concurrency freedom-patch, which is no longer required now that cross-thread connection use is controlled by the mutex.

For the original root cause of this issue, see https://github.com/rails/rails/pull/38577
This commit is contained in:
David Taylor
2022-02-03 10:00:28 +00:00
committed by GitHub
parent d0d8e25092
commit 3f6c2f82d0
3 changed files with 4 additions and 31 deletions

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
class MiniSqlMultisiteConnection < MiniSql::Postgres::Connection
class MiniSqlMultisiteConnection < MiniSql::ActiveRecordPostgres::Connection
class 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.connection
end
# make for a multisite friendly prepared statement cache