From d8cd912769f2dd5c5e16faf5cceee77b524a82e0 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 15 Jun 2020 14:33:30 +0800 Subject: [PATCH] DEV: Switch to db config to disable advisory locks. --- app/models/global_setting.rb | 1 + config/discourse_defaults.conf | 2 ++ lib/freedom_patches/postgresql_adapter.rb | 10 ---------- 3 files changed, 3 insertions(+), 10 deletions(-) delete mode 100644 lib/freedom_patches/postgresql_adapter.rb diff --git a/app/models/global_setting.rb b/app/models/global_setting.rb index c32b2b2e083..1d8df226791 100644 --- a/app/models/global_setting.rb +++ b/app/models/global_setting.rb @@ -151,6 +151,7 @@ class GlobalSetting hash["prepared_statements"] = !!self.db_prepared_statements hash["idle_timeout"] = connection_reaper_age if connection_reaper_age.present? hash["reaping_frequency"] = connection_reaper_interval if connection_reaper_interval.present? + hash["advisory_locks"] = !!self.db_advisory_locks { "production" => hash } end diff --git a/config/discourse_defaults.conf b/config/discourse_defaults.conf index b2b2aff03ed..b714d8161e1 100644 --- a/config/discourse_defaults.conf +++ b/config/discourse_defaults.conf @@ -59,6 +59,8 @@ db_replica_host = # port running replica db server, defaults to 5432 if not set db_replica_port = +db_advisory_locks = true + # hostname running the forum hostname = "www.example.com" diff --git a/lib/freedom_patches/postgresql_adapter.rb b/lib/freedom_patches/postgresql_adapter.rb deleted file mode 100644 index c790461f93f..00000000000 --- a/lib/freedom_patches/postgresql_adapter.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -# Awaiting decision on https://github.com/rails/rails/issues/31190 -if ENV['DISABLE_MIGRATION_ADVISORY_LOCK'] - class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter - def supports_advisory_locks? - false - end - end -end