From 337ef60303bbc20619004fc6e5daa284eb59383c Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 9 Nov 2021 12:06:06 +1100 Subject: [PATCH] DEV: increase lock timeout for multisite migration (#14831) - Increase lock timeout - given multisites may take a while to migrate - Ensure we do not check for status while db is migrating --- lib/tasks/db.rake | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 3230357df38..fa5e26db162 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -114,7 +114,7 @@ task 'multisite:migrate' => ['db:load_config', 'environment', 'set_locale'] do | raise "Multisite migrate is only supported in production" end - DistributedMutex.synchronize('db_migration', redis: Discourse.redis.without_namespace, validity: 300) do + DistributedMutex.synchronize('db_migration', redis: Discourse.redis.without_namespace, validity: 1200) do # TODO: Switch to processes for concurrent migrations because Rails migration # is not thread safe by default. concurrency = 1 @@ -548,12 +548,14 @@ end desc 'Check that the DB can be accessed' task 'db:status:json' do - begin - Rake::Task['environment'].invoke - DB.query('SELECT 1') - rescue - puts({ status: 'error' }.to_json) - else - puts({ status: 'ok' }.to_json) + DistributedMutex.synchronize('db_migration', redis: Discourse.redis.without_namespace, validity: 1200) do + begin + Rake::Task['environment'].invoke + DB.query('SELECT 1') + rescue + puts({ status: 'error' }.to_json) + else + puts({ status: 'ok' }.to_json) + end end end