* Create a new load balancer object. The resulting object will be untracked,
* not chronology-protected, and the caller is responsible for cleaning it up.
*
+ * This method is for only advanced usage and callers should almost always use
+ * getMainLB() instead. This method can be useful when a table is used as a key/value
+ * store. In that cases, one might want to query it in autocommit mode (DBO_TRX off)
+ * but still use DBO_TRX transaction rounds on other tables.
+ *
* @param bool|string $domain Domain ID, or false for the current domain
* @return ILoadBalancer
*/
* untracked, not chronology-protected, and the caller is responsible for
* cleaning it up.
*
+ * This method is for only advanced usage and callers should almost always use
+ * getExternalLB() instead. This method can be useful when a table is used as a
+ * key/value store. In that cases, one might want to query it in autocommit mode
+ * (DBO_TRX off) but still use DBO_TRX transaction rounds on other tables.
+ *
* @param string $cluster External storage cluster, or false for core
* @param bool|string $domain Domain ID, or false for the current domain
* @return ILoadBalancer
*/
- abstract protected function newExternalLB( $cluster, $domain = false );
+ abstract public function newExternalLB( $cluster, $domain = false );
/**
* Get a cached (tracked) load balancer for external storage
* This makes sense when lag being waiting on is caused by the code that does this check.
* In that case, setting "ifWritesSince" can avoid the overhead of waiting for clusters
* that were not changed since the last wait check. To forcefully wait on a specific cluster
- * for a given wiki, use the 'wiki' parameter. To forcefully wait on an "external" cluster,
+ * for a given domain, use the 'domain' parameter. To forcefully wait on an "external" cluster,
* use the "cluster" parameter.
*
* Never call this function after a large DB write that is *still* in a transaction.
* It only makes sense to call this after the possible lag inducing changes were committed.
*
* @param array $opts Optional fields that include:
- * - wiki : wait on the load balancer DBs that handles the given wiki
+ * - domain : wait on the load balancer DBs that handles the given domain ID
* - cluster : wait on the given external load balancer DBs
* - timeout : Max wait time. Default: ~60 seconds
* - ifWritesSince: Only wait if writes were done since this UNIX timestamp
*/
public function waitForReplication( array $opts = [] ) {
$opts += [
- 'wiki' => false,
+ 'domain' => false,
'cluster' => false,
'timeout' => 60,
'ifWritesSince' => null
];
+ if ( $opts['domain'] === false && isset( $opts['wiki'] ) ) {
+ $opts['domain'] = $opts['wiki']; // b/c
+ }
+
// Figure out which clusters need to be checked
/** @var ILoadBalancer[] $lbs */
$lbs = [];
if ( $opts['cluster'] !== false ) {
$lbs[] = $this->getExternalLB( $opts['cluster'] );
- } elseif ( $opts['wiki'] !== false ) {
- $lbs[] = $this->getMainLB( $opts['wiki'] );
+ } elseif ( $opts['domain'] !== false ) {
+ $lbs[] = $this->getMainLB( $opts['domain'] );
} else {
$this->forEachLB( function ( ILoadBalancer $lb ) use ( &$lbs ) {
$lbs[] = $lb;
*/
public function getEmptyTransactionTicket( $fname ) {
if ( $this->hasMasterChanges() ) {
- $this->queryLogger->error( __METHOD__ . ": $fname does not have outer scope." );
+ $this->queryLogger->error( __METHOD__ . ": $fname does not have outer scope.\n" .
+ ( new RuntimeException() )->getTraceAsString() );
+
return null;
}
*/
public function commitAndWaitForReplication( $fname, $ticket, array $opts = [] ) {
if ( $ticket !== $this->ticket ) {
- $this->perfLogger->error( __METHOD__ . ": $fname does not have outer scope." );
+ $this->perfLogger->error( __METHOD__ . ": $fname does not have outer scope.\n" .
+ ( new RuntimeException() )->getTraceAsString() );
+
return;
}