rdbms: cleanup code for read-only propagation for master connections
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 8 May 2019 16:13:37 +0000 (09:13 -0700)
committerKrinkle <krinklemail@gmail.com>
Thu, 30 May 2019 22:54:49 +0000 (22:54 +0000)
commit95e2c990940fa97a6b5f4d05c46ecb8d9dcf251b
tree50a4253bcebf21f4e9332fc7fc019113cb04cdb1
parent8669e0fbe6c3ca977dd14f7057de1b9f4da41c55
rdbms: cleanup code for read-only propagation for master connections

Make "readOnlyReason" immediately propagate from LoadBalancer to the
DB handle even when getConnection() with DB_REPLICA yields a master
DB handle. This can happen when the master has a non-zero "load".
Previously, it would not be set until something later used DB_MASTER
with getConnection(). This didn't really effect anything but seemed
confusing.

Short-circuit getLaggedReplicaMode() when the reader index uses the
master DB since there is no chance of lag. Also simplify it to just
calling getReaderIndex(), which since nothing else is needed to set
the "laggedReplicaMode" field.

Also rename "readerIndex" field to "genericReadIndex" and "loads"
field to "genericLoads" for clarity.

Change-Id: I6dc28933d2f94f0de1e8f9c5b2b8d2cf8a1a9d08
includes/libs/rdbms/loadbalancer/ILoadBalancer.php
includes/libs/rdbms/loadbalancer/LoadBalancer.php