@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[phabricator] Add mysql slave and read-only database connections

Summary:
Add ability to define mysql slaves and then use that connection on 'r'
connection modes. 'w' connections go to the master server.

Test Plan:
- php -l and checkModule
- worked in my devbox

Reviewed By: jungejason
Reviewers: dpepper, tuomaspelkonen, jungejason
CC: jungejason, aran
Revert Plan:
sure

Differential Revision: 175

gpatangay 4a298125 6fb24ba4

+18 -9
+6
conf/default.conf.php
··· 111 111 // The MySQL server to connect to. 112 112 'mysql.host' => 'localhost', 113 113 114 + // READ-ONLY database connection information 115 + // If you have a read-only slave mysql server, then you can fill out the 116 + // below fields. If not, duplicate the above information for the slave. 117 + 'mysql_slave.user' => 'root', 118 + 'mysql_slave.pass' => '', 119 + 'mysql_slave.host' => 'localhost', 114 120 115 121 // -- Email ----------------------------------------------------------------- // 116 122
+7 -3
src/applications/base/storage/lisk/PhabricatorLiskDAO.php
··· 20 20 abstract class PhabricatorLiskDAO extends LiskDAO { 21 21 22 22 public function establishConnection($mode) { 23 + $mysql_key = 'mysql'; 24 + if ($mode == 'r') { 25 + $mysql_key = 'mysql_slave'; 26 + } 23 27 return new AphrontMySQLDatabaseConnection( 24 28 array( 25 - 'user' => PhabricatorEnv::getEnvConfig('mysql.user'), 26 - 'pass' => PhabricatorEnv::getEnvConfig('mysql.pass'), 27 - 'host' => PhabricatorEnv::getEnvConfig('mysql.host'), 29 + 'user' => PhabricatorEnv::getEnvConfig($mysql_key.'.user'), 30 + 'pass' => PhabricatorEnv::getEnvConfig($mysql_key.'.pass'), 31 + 'host' => PhabricatorEnv::getEnvConfig($mysql_key.'.host'), 28 32 'database' => 'phabricator_'.$this->getApplicationName(), 29 33 )); 30 34
+5 -6
src/storage/lisk/dao/LiskDAO.php
··· 159 159 const IDS_PHID = 'ids-phid'; 160 160 const IDS_MANUAL = 'ids-manual'; 161 161 162 + private $__connections = array(); 163 + 162 164 /** 163 165 * Build an empty object. 164 166 * ··· 601 603 throw new Exception("Unknown mode '{$mode}', should be 'r' or 'w'."); 602 604 } 603 605 604 - // TODO: We don't do anything with the read/write mode right now, but 605 - // should. 606 - 607 - if (!isset($this->__connection)) { 608 - $this->__connection = $this->establishConnection($mode); 606 + if (!isset($this->__connections[$mode])) { 607 + $this->__connections[$mode] = $this->establishConnection($mode); 609 608 } 610 609 611 - return $this->__connection; 610 + return $this->__connections[$mode]; 612 611 } 613 612 614 613