From 4cae4a3b767fb505c32efd7ab7d8c6c185c59b96 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 07 Sep 2017 21:52:38 +0000 Subject: [PATCH] Correct `bin/storage analyze` internal API for cluster environments Summary: Ref T12819. This worked right in a non-cluster environment, but `bin/storage upgrade` iterates over each master in a partitioned cluster environment. Tweak the API so `bin/storage analyze` targets a single host but `bin/storage upgrade` can hit all the masters. Test Plan: Will run `bin/storage upgrade` in production again. Ran `upgrade` and `analyze` locally, still work fine. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12819 Differential Revision: https://secure.phabricator.com/D18576 --- src/infrastructure/storage/management/workflow/PhabricatorStorageManagementAnalyzeWorkflow.php | 3 ++- src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php | 7 ++++--- 2 file(s) changed, 6 insertion(s)(+), 4 deletion(s)(-) diff --git a/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementAnalyzeWorkflow.php b/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementAnalyzeWorkflow.php --- a/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementAnalyzeWorkflow.php +++ b/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementAnalyzeWorkflow.php @@ -12,7 +12,8 @@ } public function didExecute(PhutilArgumentParser $args) { - $this->analyzeTables(); + $api = $this->getSingleAPI(); + $this->analyzeTables($api); return 0; } diff --git a/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php b/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php --- a/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php +++ b/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php @@ -143,7 +143,7 @@ if (!$this->dryRun) { $should_analyze = (($err == 0) || ($err == 2)); if ($should_analyze) { - $this->analyzeTables(); + $this->analyzeTables($api); } } } catch (Exception $ex) { @@ -1172,12 +1172,13 @@ ->lock(); } - final protected function analyzeTables() { + final protected function analyzeTables( + PhabricatorStorageManagementAPI $api) { + // Analyzing tables can sometimes have a significant effect on query // performance, particularly for the fulltext ngrams tables. See T12819 // for some specific examples. - $api = $this->getSingleAPI(); $conn = $api->getConn(null); $patches = $this->getPatches(); -- tangled.sh