rdbms: specify DB name and table prefix even for the local domain
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 12 Jan 2018 21:44:12 +0000 (13:44 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 16 Jan 2018 17:06:52 +0000 (17:06 +0000)
commit14ee3f2107826495b8ef0d50e0340394bf28c92d
treee15453312576db4703b335a4bd83bb1a1a9d0dc8
parent79d298e37f8aeb42ccf43155a5be3c16b7688901
rdbms: specify DB name and table prefix even for the local domain

When LoadBalancer opens new local domain connections, it currently
assumes that the domain specified by the server info array is the
same. For sanity, make sure that the handle is set to the local
domain.

The main LBFactory/LoadBalancer use $wgDBname/$wgDBprefix as the
local domain, corresponding with wfWikiId(). This relation is set
automatically in MWLBFactory. If $wgLBFactoryConf/$wgDBservers is
manually configured in a way breaking this correspondance, then it
is misconfigured.

Fixes made to avoid test failure:
* Make sure LoadBalancer::setDomainPrefix() updates the local
  domain alias member. Also do not bother changing the domain of
  foreign connections.
* Use the right domain ID for the connection array key names in
  LoadBalancer::openForeignConnection().
* Now that JobQueueTest no longer mistakenly uses the non-test
  tables, force it to use the main DB_MASTER handle so that it can
  see the unit test tables even if they are TEMPORARY; such tables
  are tied to the TCP connection, so separate handles see different
  temporary tables.

Change-Id: I56f8b32fe957f984b8c9753e6db3b20abe96b038
includes/libs/rdbms/loadbalancer/LoadBalancer.php
includes/libs/rdbms/loadbalancer/LoadBalancerSingle.php
tests/phpunit/includes/Storage/RevisionStoreDbTest.php
tests/phpunit/includes/db/LBFactoryTest.php
tests/phpunit/includes/jobqueue/JobQueueTest.php