rdbms: clean up $groups logic in LoadBalancer and expand comments
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 24 Jun 2019 23:36:42 +0000 (16:36 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 4 Jul 2019 22:26:55 +0000 (22:26 +0000)
commitab09cf2fa59f35202f74c660ba84105acc02d919
tree283a62ae11a69ca12b5d031bd89971dae70acda1
parent4c3b7441f06a177c5ac7a51d01371d29d66704ad
rdbms: clean up $groups logic in LoadBalancer and expand comments

Split out private resolveGroups() method for normalizing query
groups. Move some server index validation to getConnectionIndex()
and make it stricter.

Make getConnectionIndex() group fallback logic aware of the generic
group. The main use case for custom default groups is heavy scripts
or jobs that run in the background. It is probably better to have
good DB server redundancy for the query group and rely on it rather
than possibly fallback onto all of the main servers used for normal
requests. The later behavior could spread slowness or outages.

Also make getAnyOpenConnection() more robust and readable by
splitting out a private pickAnyOpenConnection() method that
checks IDatabase::trxLevel().

In addition, remove redundant is_int() check from isOpen()
method as it will return false in that case even without it.

Remove bogus getConnection() parameter in testCopyTestData().

Change-Id: Ica619c5487c761c724791d151db7388e4b41b0aa
includes/libs/rdbms/database/DBConnRef.php
includes/libs/rdbms/loadbalancer/ILoadBalancer.php
includes/libs/rdbms/loadbalancer/LoadBalancer.php
tests/phpunit/includes/db/LoadBalancerTest.php
tests/phpunit/tests/MediaWikiTestCaseTest.php