From cb1d90465447c8a7cc5bc42aa2566c12692fec25 Mon Sep 17 00:00:00 2001 From: Mukunda Modell Date: Thu, 30 Mar 2017 18:08:05 +0000 Subject: [PATCH] Make sure writes go to the right cluster Summary: Two little issues 1. there was an extra call to getHostForWrite, 2. The engine instance was shared between multiple service definitions so it was overwriting the list of writable hosts from one service with hosts from another. Test Plan: tested in wikimedia production with multiple services defined like this: ```language=json [ { "hosts": [ { "host": "search.svc.codfw.wmnet", "protocol": "https", "roles": { "read": true, "write": true }, "version": 5 } ], "path": "/phabricator", "port": 9243, "type": "elasticsearch" }, { "hosts": [ { "host": "search.svc.eqiad.wmnet", "protocol": "https", "roles": { "read": true, "write": true }, "version": 5 } ], "path": "/phabricator", "port": 9243, "type": "elasticsearch" } ] ``` Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D17581 --- .../fulltextstorage/PhabricatorElasticFulltextStorageEngine.php | 1 - src/infrastructure/cluster/search/PhabricatorSearchService.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php b/src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php index 2e456ec408..45011ba982 100644 --- a/src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php +++ b/src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php @@ -528,7 +528,6 @@ class PhabricatorElasticFulltextStorageEngine $host = $this->getHostForRead(); } $uri = '/_stats/'; - $host = $this->getHostForRead(); $res = $this->executeRequest($host, $uri, array()); $stats = $res['indices'][$this->index]; diff --git a/src/infrastructure/cluster/search/PhabricatorSearchService.php b/src/infrastructure/cluster/search/PhabricatorSearchService.php index 59ef7c408d..10cf78d94b 100644 --- a/src/infrastructure/cluster/search/PhabricatorSearchService.php +++ b/src/infrastructure/cluster/search/PhabricatorSearchService.php @@ -198,7 +198,7 @@ class PhabricatorSearchService implode(', ', array_keys($engines)))); } - $engine = $engines[$config['type']]; + $engine = clone($engines[$config['type']]); $cluster = new self($engine); $cluster->setConfig($config); $engine->setService($cluster);