From d4388f54a24953457c8f386b72cb25a910b50e4a Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Wed, 27 Sep 2017 11:55:06 +0800 Subject: [PATCH] FIX: Use exact patht to ensure we always redirect with the right format. --- config/database.yml | 4 ++-- config/sidekiq.yml | 2 +- .../postgresql_fallback_adapter.rb | 9 +-------- .../postgresql_fallback_adapter_spec.rb | 11 ++--------- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/config/database.yml b/config/database.yml index 1b51d1079f2..c1575122620 100644 --- a/config/database.yml +++ b/config/database.yml @@ -3,7 +3,7 @@ development: adapter: postgresql database: <%= ENV['DISCOURSE_DEV_DB'] || 'discourse_development' %> min_messages: warning - pool: 10 + pool: 5 timeout: 5000 host_names: ### Don't include the port number here. Change the "port" site setting instead, at /admin/site_settings. @@ -20,7 +20,7 @@ test: adapter: postgresql database: discourse_test<%= ENV['MULTISITE'] ? "_#{ENV['MULTISITE']}" : '' %> min_messages: warning - pool: 10 + pool: 5 timeout: 5000 host_names: - test.localhost diff --git a/config/sidekiq.yml b/config/sidekiq.yml index 3f94e6a21b8..a3ed5fc5f09 100644 --- a/config/sidekiq.yml +++ b/config/sidekiq.yml @@ -1,6 +1,6 @@ --- development: - :concurrency: 5 + :concurrency: 1 :queues: - [critical,4] - [default, 2] diff --git a/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb b/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb index e16136bc1e0..1e2e84f8c6a 100644 --- a/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb +++ b/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb @@ -119,14 +119,7 @@ module ActiveRecord def verify_replica(connection) value = connection.raw_connection.exec("SELECT pg_is_in_recovery()").values[0][0] - - if !value - begin - raise "Replica database server is not in recovery mode." - ensure - connection.close - end - end + raise "Replica database server is not in recovery mode." if !value end end end diff --git a/spec/components/active_record/connection_adapters/postgresql_fallback_adapter_spec.rb b/spec/components/active_record/connection_adapters/postgresql_fallback_adapter_spec.rb index e7889dd514c..036c990d894 100644 --- a/spec/components/active_record/connection_adapters/postgresql_fallback_adapter_spec.rb +++ b/spec/components/active_record/connection_adapters/postgresql_fallback_adapter_spec.rb @@ -94,15 +94,8 @@ describe ActiveRecord::ConnectionHandling do expect(postgresql_fallback_handler.master_down?).to eq(nil) expect(ActiveRecord::Base.connection_pool.connections.count).to eq(0) - ActiveRecord::Base.clear_all_connections! - connection = ActiveRecord::Base.connection - - begin - expect(connection) - .to be_an_instance_of(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) - ensure - connection.close - end + expect(ActiveRecord::Base.connection) + .to be_an_instance_of(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) end end