rdbms: avoid recursion in LoadBalancer when the master has non-zero load
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 27 Jun 2019 18:52:04 +0000 (11:52 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 9 Jul 2019 19:26:46 +0000 (19:26 +0000)
commit79d1881eded1537e739c92d3576c48e34b352f88
treede055d13a4b0c0e1e1fbf7677422193abd1cd2f2
parent57d053385f00b4c345dcc9c412162613b0d2a342
rdbms: avoid recursion in LoadBalancer when the master has non-zero load

Add and use IDatabase::getServerConnection() method to avoid loops caused
caused by pickReaderIndex() calling getConnection() for the master server.
That lead to getReadOnlyReason() triggering pickReaderIndex() again.

Make getLaggedReplicaMode() apply when the master has non-zero load and
the replicas are all lagged.

Remove "allReplicasDownMode" in favor of checking getExistingReaderIndex()
instead. This reduces the amount of state to keep track of a bit.

Follow-up to 95e2c990940f

Bug: T226678
Bug: T226770
Change-Id: Id932c3fcc00625e3960f76d054d38d9679d25ecc
includes/libs/rdbms/loadbalancer/ILoadBalancer.php
includes/libs/rdbms/loadbalancer/LoadBalancer.php
includes/libs/rdbms/loadmonitor/LoadMonitor.php
tests/phpunit/includes/db/LoadBalancerTest.php