More master -> primary documentation and internal var renaming
Bug: T254646 Change-Id: I63cc8895033714bdfbf09aee933a8f0a43b387f3
This commit is contained in:
parent
cf30859be2
commit
719cf161f2
38 changed files with 101 additions and 101 deletions
|
|
@ -385,8 +385,8 @@ abstract class Handler {
|
|||
* the database.
|
||||
*
|
||||
* This should return true for routes that may require synchronous database writes.
|
||||
* Modules that do not need such writes should also not rely on master database access,
|
||||
* since only read queries are needed and each master DB is a single point of failure.
|
||||
* Modules that do not need such writes should also not rely on primary database access,
|
||||
* since only read queries are needed and each primary DB is a single point of failure.
|
||||
*
|
||||
* @stable to override
|
||||
*
|
||||
|
|
|
|||
|
|
@ -124,9 +124,9 @@ class RevisionRenderer {
|
|||
);
|
||||
}
|
||||
|
||||
$useMaster = $hints['use-master'] ?? false;
|
||||
$usePrimary = $hints['use-master'] ?? false;
|
||||
|
||||
$dbIndex = $useMaster
|
||||
$dbIndex = $usePrimary
|
||||
? DB_PRIMARY // use latest values
|
||||
: DB_REPLICA; // T154554
|
||||
|
||||
|
|
|
|||
|
|
@ -1376,7 +1376,7 @@ class RevisionStore
|
|||
);
|
||||
|
||||
if ( !$res->numRows() && !( $queryFlags & self::READ_LATEST ) ) {
|
||||
// If we found no slots, try looking on the master database (T212428, T252156)
|
||||
// If we found no slots, try looking on the primary database (T212428, T252156)
|
||||
$this->logger->info(
|
||||
__METHOD__ . ' falling back to READ_LATEST.',
|
||||
[
|
||||
|
|
@ -1723,7 +1723,7 @@ class RevisionStore
|
|||
[ 'rev_id' => intval( $revId ) ]
|
||||
);
|
||||
if ( !$row && !( $queryFlags & self::READ_LATEST ) ) {
|
||||
// If we found no slots, try looking on the master database (T259738)
|
||||
// If we found no slots, try looking on the primary database (T259738)
|
||||
$this->logger->info(
|
||||
'RevisionStoreCacheRecord refresh callback falling back to READ_LATEST.',
|
||||
[
|
||||
|
|
@ -2226,7 +2226,7 @@ class RevisionStore
|
|||
*
|
||||
* This method should be used if we are pretty sure the revision exists.
|
||||
* Unless $flags has READ_LATEST set, this method will first try to find the revision
|
||||
* on a replica before hitting the master database.
|
||||
* on a replica before hitting the primary database.
|
||||
*
|
||||
* MCR migration note: this corresponded to Revision::newFromConds
|
||||
*
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ class NameTableStore {
|
|||
}
|
||||
|
||||
/**
|
||||
* Reloads the name table from the master database, and purges the WAN cache entry.
|
||||
* Reloads the name table from the primary database, and purges the WAN cache entry.
|
||||
*
|
||||
* @note This should only be called in situations where the local cache has been detected
|
||||
* to be out of sync with the database. There should be no reason to call this method
|
||||
|
|
@ -294,12 +294,12 @@ class NameTableStore {
|
|||
// Use the old value
|
||||
return $oldValue;
|
||||
}
|
||||
// Regenerate from replica DB, and master DB if needed
|
||||
// Regenerate from replica DB, and primary DB if needed
|
||||
foreach ( [ DB_REPLICA, DB_PRIMARY ] as $source ) {
|
||||
// Log a fallback to master
|
||||
// Log a fallback to primary
|
||||
if ( $source === DB_PRIMARY ) {
|
||||
$this->logger->info(
|
||||
$fname . ' falling back to master select from ' .
|
||||
$fname . ' falling back to primary select from ' .
|
||||
$this->table . ' with id ' . $id
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ class PageEditStash {
|
|||
$key = $this->getStashKey( $page, $this->getContentHash( $content ), $user );
|
||||
$fname = __METHOD__;
|
||||
|
||||
// Use the master DB to allow for fast blocking locks on the "save path" where this
|
||||
// Use the primary DB to allow for fast blocking locks on the "save path" where this
|
||||
// value might actually be used to complete a page edit. If the edit submission request
|
||||
// happens before this edit stash requests finishes, then the submission will block until
|
||||
// the stash request finishes parsing. For the lock acquisition below, there is not much
|
||||
|
|
|
|||
|
|
@ -760,7 +760,7 @@ class PageUpdater {
|
|||
}
|
||||
}
|
||||
|
||||
// Load the data from the master database if needed. Needed to check flags.
|
||||
// Load the data from the primary database if needed. Needed to check flags.
|
||||
// NOTE: This grabs the parent revision as the CAS token, if grabParentRevision
|
||||
// wasn't called yet. If the page is modified by another process before we are done with
|
||||
// it, this method must fail (with status 'edit-conflict')!
|
||||
|
|
|
|||
2
includes/cache/LinkCache.php
vendored
2
includes/cache/LinkCache.php
vendored
|
|
@ -111,7 +111,7 @@ class LinkCache implements LoggerAwareInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* General accessor to get/set whether the master DB should be used
|
||||
* General accessor to get/set whether the primary DB should be used
|
||||
*
|
||||
* This used to also set the FOR UPDATE option (locking the rows read
|
||||
* in order to avoid link table inconsistency), which was later removed
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ class ExternalStoreDB extends ExternalStoreMedium {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param array $server Master DB server configuration array for LoadBalancer
|
||||
* @param array $server Primary DB server configuration array for LoadBalancer
|
||||
* @return string|bool Database domain ID or false
|
||||
*/
|
||||
private function getDomainId( array $server ) {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class ReplicatedBagOStuff extends BagOStuff {
|
|||
/**
|
||||
* Constructor. Parameters are:
|
||||
* - writeFactory: ObjectFactory::getObjectFromSpec array yielding BagOStuff.
|
||||
* This object will be used for writes (e.g. the master DB).
|
||||
* This object will be used for writes (e.g. the primary DB).
|
||||
* - readFactory: ObjectFactory::getObjectFromSpec array yielding BagOStuff.
|
||||
* This object will be used for reads (e.g. a replica DB).
|
||||
* - sessionConsistencyWindow: Seconds to read from the master source for a key
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ use Wikimedia\WaitConditionLoop;
|
|||
* These are the expectations a site administrator must meet for chronology protection:
|
||||
*
|
||||
* - If the application is run from multiple data centers, then you must designate one of them
|
||||
* as the "primary DC". The primary DC is where the master database is located, from which
|
||||
* as the "primary DC". The primary DC is where the primary database is located, from which
|
||||
* replication propagates to replica databases in that same DC and any other DCs.
|
||||
*
|
||||
* - Web requests that use the POST verb, or carry a `UseDC=master` cookie, must be routed to
|
||||
|
|
@ -125,7 +125,7 @@ use Wikimedia\WaitConditionLoop;
|
|||
* An exception is requests carrying the `Promise-Non-Write-API-Action: true` header,
|
||||
* which use the POST verb for large read queries, but don't actually require the primary DC.
|
||||
*
|
||||
* If you have legacy extensions deployed that perform queries on the master database during
|
||||
* If you have legacy extensions deployed that perform queries on the primary database during
|
||||
* GET requests, then you will have to identify a way to route any of its relevant URLs to the
|
||||
* primary DC as well, or to accept that their reads do not enjoy chronology protection, and
|
||||
* that writes may be slower (due to cross-dc latency).
|
||||
|
|
@ -278,7 +278,7 @@ class ChronologyProtector implements LoggerAwareInterface {
|
|||
/**
|
||||
* Update client "session consistency" replication position for an end-of-life ILoadBalancer
|
||||
*
|
||||
* This remarks the replication position of the master DB if this request made writes to
|
||||
* This remarks the replication position of the primary DB if this request made writes to
|
||||
* it using the provided ILoadBalancer instance.
|
||||
*
|
||||
* @internal This method should only be called from LBFactory.
|
||||
|
|
|
|||
|
|
@ -204,9 +204,9 @@ class TransactionProfiler implements LoggerAwareInterface {
|
|||
*
|
||||
* @param string $server DB server
|
||||
* @param string|null $db DB name
|
||||
* @param bool $isMaster
|
||||
* @param bool $isPrimary
|
||||
*/
|
||||
public function recordConnection( $server, $db, bool $isMaster ) {
|
||||
public function recordConnection( $server, $db, bool $isPrimary ) {
|
||||
// Report when too many connections happen...
|
||||
if ( $this->pingAndCheckThreshold( 'conns' ) ) {
|
||||
$this->reportExpectationViolated(
|
||||
|
|
@ -216,8 +216,8 @@ class TransactionProfiler implements LoggerAwareInterface {
|
|||
);
|
||||
}
|
||||
|
||||
// Report when too many master connections happen...
|
||||
if ( $isMaster && $this->pingAndCheckThreshold( 'masterConns' ) ) {
|
||||
// Report when too many primary connections happen...
|
||||
if ( $isPrimary && $this->pingAndCheckThreshold( 'masterConns' ) ) {
|
||||
$this->reportExpectationViolated(
|
||||
'masterConns',
|
||||
"[connect to $server ($db)]",
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ class ConnectionManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a connection to the master DB, for updating. The connection should later be released
|
||||
* Returns a connection to the primary DB, for updating. The connection should later be released
|
||||
* by calling releaseConnection().
|
||||
*
|
||||
* @since 1.29
|
||||
|
|
@ -145,7 +145,7 @@ class ConnectionManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a connection ref to the master DB, for updating.
|
||||
* Returns a connection ref to the primary DB, for updating.
|
||||
*
|
||||
* @since 1.29
|
||||
*
|
||||
|
|
|
|||
|
|
@ -24,18 +24,18 @@ namespace Wikimedia\Rdbms;
|
|||
/**
|
||||
* Database connection manager.
|
||||
*
|
||||
* This manages access to master and replica databases. It also manages state that indicates whether
|
||||
* the replica databases are possibly outdated after a write operation, and thus the master database
|
||||
* This manages access to primary and replica databases. It also manages state that indicates whether
|
||||
* the replica databases are possibly outdated after a write operation, and thus the primary database
|
||||
* should be used for subsequent read operations.
|
||||
*
|
||||
* @note: Services that access overlapping sets of database tables, or interact with logically
|
||||
* related sets of data in the database, should share a SessionConsistentConnectionManager.
|
||||
* Services accessing unrelated sets of information may prefer to not share a
|
||||
* SessionConsistentConnectionManager, so they can still perform read operations against replica
|
||||
* databases after a (unrelated, per the assumption) write operation to the master database.
|
||||
* databases after a (unrelated, per the assumption) write operation to the primary database.
|
||||
* Generally, sharing a SessionConsistentConnectionManager improves consistency (by avoiding race
|
||||
* conditions due to replication lag), but can reduce performance (by directing more read
|
||||
* operations to the master database server).
|
||||
* operations to the primary database server).
|
||||
*
|
||||
* @since 1.29
|
||||
*
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class DBConnRef implements IDatabase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return int DB_PRIMARY when this *requires* the master DB, otherwise DB_REPLICA
|
||||
* @return int DB_PRIMARY when this *requires* the primary DB, otherwise DB_REPLICA
|
||||
* @since 1.33
|
||||
*/
|
||||
public function getReferenceRole() {
|
||||
|
|
@ -775,12 +775,12 @@ class DBConnRef implements IDatabase {
|
|||
* Error out if the role is not DB_PRIMARY
|
||||
*
|
||||
* Note that the underlying connection may or may not itself be read-only.
|
||||
* It could even be to a writable master (both server-side and to the application).
|
||||
* It could even be to a writable primary (both server-side and to the application).
|
||||
* This error is meant for the case when a DB_REPLICA handle was requested but a
|
||||
* a write was attempted on that handle regardless.
|
||||
*
|
||||
* In configurations where the master DB has some generic read load or is the only server,
|
||||
* DB_PRIMARY/DB_REPLICA will sometimes (or always) use the same connection to the master DB.
|
||||
* In configurations where the primary DB has some generic read load or is the only server,
|
||||
* DB_PRIMARY/DB_REPLICA will sometimes (or always) use the same connection to the primary DB.
|
||||
* This does not effect the role of DBConnRef instances.
|
||||
* @throws DBReadOnlyRoleError
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
|
|||
/** @var object|resource|null Database connection */
|
||||
protected $conn;
|
||||
|
||||
/** @var IDatabase|null Lazy handle to the master DB this server replicates from */
|
||||
/** @var IDatabase|null Lazy handle to the primary DB this server replicates from */
|
||||
private $lazyMasterHandle;
|
||||
|
||||
/** @var string|null Server that this instance is currently connected to */
|
||||
|
|
@ -93,7 +93,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
|
|||
protected $agent;
|
||||
/** @var string Replication topology role of the server; one of the class ROLE_* constants */
|
||||
protected $topologyRole;
|
||||
/** @var string|null Host (or address) of the root master server for the replication topology */
|
||||
/** @var string|null Host (or address) of the root primary server for the replication topology */
|
||||
protected $topologyRootMaster;
|
||||
/** @var array<string,mixed> Connection parameters used by initConnection() and open() */
|
||||
protected $connectionParams;
|
||||
|
|
@ -411,7 +411,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
|
|||
* - lbInfo: Optional map of field/values for the managing load balancer instance.
|
||||
* The "master" and "replica" fields are used to flag the replication role of this
|
||||
* database server and whether methods like getLag() should actually issue queries.
|
||||
* - lazyMasterHandle: lazy-connecting IDatabase handle to the master DB for the cluster
|
||||
* - lazyMasterHandle: lazy-connecting IDatabase handle to the primary DB for the cluster
|
||||
* that this database belongs to. This is used for replication status purposes.
|
||||
* - connLogger: Optional PSR-3 logger interface instance.
|
||||
* - queryLogger: Optional PSR-3 logger interface instance.
|
||||
|
|
|
|||
|
|
@ -853,7 +853,7 @@ abstract class DatabaseMysqlBase extends Database {
|
|||
$this->getLogContext( [ 'method' => __METHOD__, 'raw_pos' => $pos ] )
|
||||
);
|
||||
|
||||
return 0; // this is a copy of a read-only dataset with no master DB
|
||||
return 0; // this is a copy of a read-only dataset with no primary DB
|
||||
} elseif ( $this->lastKnownReplicaPos && $this->lastKnownReplicaPos->hasReached( $pos ) ) {
|
||||
$this->queryLogger->debug(
|
||||
"Bypassed replication wait; replication known to have reached {raw_pos}",
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ interface ILBFactory {
|
|||
*
|
||||
* @param array $conf Array with keys:
|
||||
* - localDomain: A DatabaseDomain or domain ID string.
|
||||
* - readOnlyReason: Reason the master DB is read-only if so [optional]
|
||||
* - readOnlyReason: Reason the primary DB is read-only if so [optional]
|
||||
* - srvCache: BagOStuff instance for server cache [optional]
|
||||
* - cpStash: BagOStuff instance for ChronologyProtector store [optional]
|
||||
* See [ChronologyProtector requirements](@ref ChronologyProtector-storage-requirements).
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ abstract class LBFactory implements ILBFactory {
|
|||
$this->forEachLBCallMethod( 'approveMasterChanges', [ $options, $fname, $this->id ] );
|
||||
// Log the DBs and methods involved in multi-DB transactions
|
||||
$this->logIfMultiDbTransaction();
|
||||
// Actually perform the commit on all master DB connections and revert DBO_TRX
|
||||
// Actually perform the commit on all primary DB connections and revert DBO_TRX
|
||||
$this->forEachLBCallMethod( 'commitMasterChanges', [ $fname, $this->id ] );
|
||||
// Run all post-commit callbacks in a separate step
|
||||
$this->trxRoundStage = self::ROUND_COMMIT_CALLBACKS;
|
||||
|
|
@ -328,7 +328,7 @@ abstract class LBFactory implements ILBFactory {
|
|||
|
||||
$this->trxRoundStage = self::ROUND_ROLLING_BACK;
|
||||
$this->trxRoundId = false;
|
||||
// Actually perform the rollback on all master DB connections and revert DBO_TRX
|
||||
// Actually perform the rollback on all primary DB connections and revert DBO_TRX
|
||||
$this->forEachLBCallMethod( 'rollbackMasterChanges', [ $fname, $this->id ] );
|
||||
// Run all post-commit callbacks in a separate step
|
||||
$this->trxRoundStage = self::ROUND_ROLLBACK_CALLBACKS;
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ class LoadBalancer implements ILoadBalancer {
|
|||
|
||||
/** Default 'waitTimeout' when unspecified */
|
||||
private const MAX_WAIT_DEFAULT = 10;
|
||||
/** Seconds to cache master DB server read-only status */
|
||||
/** Seconds to cache primary DB server read-only status */
|
||||
private const TTL_CACHE_READONLY = 5;
|
||||
|
||||
private const KEY_LOCAL = 'local';
|
||||
|
|
@ -362,7 +362,7 @@ class LoadBalancer implements ILoadBalancer {
|
|||
* @return int Sanitized bitfield
|
||||
*/
|
||||
private function sanitizeConnectionFlags( $flags, $i, $domain ) {
|
||||
// Whether an outside caller is explicitly requesting the master database server
|
||||
// Whether an outside caller is explicitly requesting the primary database server
|
||||
if ( $i === self::DB_PRIMARY || $i === $this->getWriterIndex() ) {
|
||||
$flags |= self::CONN_INTENT_WRITABLE;
|
||||
}
|
||||
|
|
@ -372,7 +372,7 @@ class LoadBalancer implements ILoadBalancer {
|
|||
// resorting to row locks (e.g. FOR UPDATE) or to make small out-of-band commits
|
||||
// during larger transactions. This is useful for avoiding lock contention.
|
||||
|
||||
// Master DB server attributes (should match those of the replica DB servers)
|
||||
// Primary DB server attributes (should match those of the replica DB servers)
|
||||
$attributes = $this->getServerAttributes( $this->getWriterIndex() );
|
||||
if ( $attributes[Database::ATTR_DB_LEVEL_LOCKING] ) {
|
||||
// The RDBMS does not support concurrent writes (e.g. SQLite), so attempts
|
||||
|
|
@ -962,7 +962,7 @@ class LoadBalancer implements ILoadBalancer {
|
|||
$serverIndex = $this->getConnectionIndex( $i, $groups, $domain );
|
||||
// Get an open connection to that server (might trigger a new connection)
|
||||
$conn = $this->getServerConnection( $serverIndex, $domain, $flags );
|
||||
// Set master DB handles as read-only if there is high replication lag
|
||||
// Set primary DB handles as read-only if there is high replication lag
|
||||
if (
|
||||
$conn &&
|
||||
$serverIndex === $this->getWriterIndex() &&
|
||||
|
|
@ -1015,15 +1015,15 @@ class LoadBalancer implements ILoadBalancer {
|
|||
|
||||
// Make sure that flags like CONN_TRX_AUTOCOMMIT are respected by this handle
|
||||
$this->enforceConnectionFlags( $conn, $flags );
|
||||
// Set master DB handles as read-only if the load balancer is configured as read-only
|
||||
// or the master database server is running in server-side read-only mode. Note that
|
||||
// Set primary DB handles as read-only if the load balancer is configured as read-only
|
||||
// or the primary database server is running in server-side read-only mode. Note that
|
||||
// replica DB handles are always read-only via Database::assertIsWritableMaster().
|
||||
// Read-only mode due to replication lag is *avoided* here to avoid recursion.
|
||||
if ( $i === $this->getWriterIndex() ) {
|
||||
if ( $this->readOnlyReason !== false ) {
|
||||
$readOnlyReason = $this->readOnlyReason;
|
||||
} elseif ( $this->isMasterConnectionReadOnly( $conn, $flags ) ) {
|
||||
$readOnlyReason = 'The master database server is running in read-only mode.';
|
||||
$readOnlyReason = 'The primary database server is running in read-only mode.';
|
||||
} else {
|
||||
$readOnlyReason = false;
|
||||
}
|
||||
|
|
@ -2125,7 +2125,7 @@ class LoadBalancer implements ILoadBalancer {
|
|||
if ( $this->readOnlyReason !== false ) {
|
||||
return $this->readOnlyReason;
|
||||
} elseif ( $this->isMasterRunningReadOnly( $domainInstance ) ) {
|
||||
return 'The master database server is running in read-only mode.';
|
||||
return 'The primary database server is running in read-only mode.';
|
||||
} elseif ( $this->getLaggedReplicaMode( $domain ) ) {
|
||||
$genericIndex = $this->getExistingReaderIndex( self::GROUP_GENERIC );
|
||||
|
||||
|
|
@ -2139,7 +2139,7 @@ class LoadBalancer implements ILoadBalancer {
|
|||
|
||||
/**
|
||||
* @note This method suppresses DBError exceptions in order to avoid severe downtime
|
||||
* @param IDatabase $conn Master connection
|
||||
* @param IDatabase $conn Primary connection
|
||||
* @param int $flags Bitfield of class CONN_* constants
|
||||
* @return bool Whether the entire server or currently selected DB/schema is read-only
|
||||
*/
|
||||
|
|
@ -2375,7 +2375,7 @@ class LoadBalancer implements ILoadBalancer {
|
|||
if ( !$masterConn ) {
|
||||
throw new DBReplicationWaitError(
|
||||
null,
|
||||
"Could not obtain a master database connection to get the position"
|
||||
"Could not obtain a primary database connection to get the position"
|
||||
);
|
||||
}
|
||||
$pos = $masterConn->getMasterPos();
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ class LoadMonitor implements ILoadMonitor {
|
|||
* @throws DBAccessError
|
||||
*/
|
||||
protected function getServerStates( array $serverIndexes, $domain ) {
|
||||
// Represent the cluster by the name of the master DB
|
||||
// Represent the cluster by the name of the primary DB
|
||||
$cluster = $this->lb->getServerName( $this->lb->getWriterIndex() );
|
||||
|
||||
// Randomize logical TTLs to reduce stampedes
|
||||
|
|
@ -199,7 +199,7 @@ class LoadMonitor implements ILoadMonitor {
|
|||
* @throws DBAccessError
|
||||
*/
|
||||
protected function computeServerStates( array $serverIndexes, $domain, $priorStates ) {
|
||||
// Check if there is just a master DB (no replication involved)
|
||||
// Check if there is just a primary DB (no replication involved)
|
||||
if ( $this->lb->getServerCount() <= 1 ) {
|
||||
return $this->getPlaceholderServerStates( $serverIndexes );
|
||||
}
|
||||
|
|
@ -209,11 +209,11 @@ class LoadMonitor implements ILoadMonitor {
|
|||
$lagTimes = [];
|
||||
$weightScales = [];
|
||||
foreach ( $serverIndexes as $i ) {
|
||||
$isMaster = ( $i == $this->lb->getWriterIndex() );
|
||||
// If the master DB has zero load, then typical read queries do not use it.
|
||||
$isPrimary = ( $i == $this->lb->getWriterIndex() );
|
||||
// If the primary DB has zero load, then typical read queries do not use it.
|
||||
// In that case, avoid connecting to it since this method might run in any
|
||||
// datacenter, and the master DB might be geographically remote.
|
||||
if ( $isMaster && $this->lb->getServerInfo( $i )['load'] <= 0 ) {
|
||||
// datacenter, and the primary DB might be geographically remote.
|
||||
if ( $isPrimary && $this->lb->getServerInfo( $i )['load'] <= 0 ) {
|
||||
$lagTimes[$i] = 0;
|
||||
// Callers only use this DB if they have *no choice* anyway (e.g. writes)
|
||||
$weightScales[$i] = 1.0;
|
||||
|
|
@ -247,7 +247,7 @@ class LoadMonitor implements ILoadMonitor {
|
|||
|
||||
// Mark replication lag on this server as "false" if it is unreacheable
|
||||
if ( !$conn ) {
|
||||
$lagTimes[$i] = $isMaster ? 0 : false;
|
||||
$lagTimes[$i] = $isPrimary ? 0 : false;
|
||||
$this->replLogger->error(
|
||||
__METHOD__ . ": host {db_server} is unreachable",
|
||||
[ 'db_server' => $host ]
|
||||
|
|
@ -361,7 +361,7 @@ class LoadMonitor implements ILoadMonitor {
|
|||
*/
|
||||
private function getStatesCacheKey( $cache, array $serverIndexes ) {
|
||||
sort( $serverIndexes );
|
||||
// Lag is per-server, not per-DB, so key on the master DB name
|
||||
// Lag is per-server, not per-DB, so key on the primary DB name
|
||||
return $cache->makeGlobalKey(
|
||||
'rdbms-server-states',
|
||||
self::VERSION,
|
||||
|
|
|
|||
|
|
@ -600,7 +600,7 @@ class LogEventsList extends ContextSource {
|
|||
* - wrap String Wrap the message in html (usually something like "<div ...>$1</div>").
|
||||
* - flags Integer display flags (NO_ACTION_LINK,NO_EXTRA_USER_LINKS)
|
||||
* - useRequestParams boolean Set true to use Pager-related parameters in the WebRequest
|
||||
* - useMaster boolean Use master DB
|
||||
* - useMaster boolean Use primary DB
|
||||
* - extraUrlParams array|bool Additional url parameters for "full log" link (if it is shown)
|
||||
* @return int Number of total log items (not limited by $lim)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1188,7 +1188,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
|
|||
}
|
||||
|
||||
/**
|
||||
* Wait for replica DBs to catch up to the master DB
|
||||
* Wait for replica DBs to catch up to the primary DB
|
||||
*
|
||||
* @param int|string $shardIndex Server index or self::SHARD_LOCAL/self::SHARD_GLOBAL
|
||||
* @return bool Success
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
|
|||
* @param int $id Article ID to load
|
||||
* @param string|int $from One of the following values:
|
||||
* - "fromdb" or WikiPage::READ_NORMAL to select from a replica DB
|
||||
* - "fromdbmaster" or WikiPage::READ_LATEST to select from the master database
|
||||
* - "fromdbmaster" or WikiPage::READ_LATEST to select from the primary database
|
||||
*
|
||||
* @return WikiPage|null
|
||||
* @deprecated since 1.36, use WikiPageFactory::newFromID instead
|
||||
|
|
@ -231,8 +231,8 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
|
|||
* @param stdClass $row Database row containing at least fields returned by getQueryInfo().
|
||||
* @param string|int $from Source of $data:
|
||||
* - "fromdb" or WikiPage::READ_NORMAL: from a replica DB
|
||||
* - "fromdbmaster" or WikiPage::READ_LATEST: from the master DB
|
||||
* - "forupdate" or WikiPage::READ_LOCKING: from the master DB using SELECT FOR UPDATE
|
||||
* - "fromdbmaster" or WikiPage::READ_LATEST: from the primary DB
|
||||
* - "forupdate" or WikiPage::READ_LOCKING: from the primary DB using SELECT FOR UPDATE
|
||||
* @return WikiPage
|
||||
* @deprecated since 1.36, use WikiPageFactory::newFromRow instead
|
||||
*/
|
||||
|
|
@ -465,8 +465,8 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
|
|||
* @param stdClass|string|int $from One of the following:
|
||||
* - A DB query result object.
|
||||
* - "fromdb" or WikiPage::READ_NORMAL to get from a replica DB.
|
||||
* - "fromdbmaster" or WikiPage::READ_LATEST to get from the master DB.
|
||||
* - "forupdate" or WikiPage::READ_LOCKING to get from the master DB
|
||||
* - "fromdbmaster" or WikiPage::READ_LATEST to get from the primary DB.
|
||||
* - "forupdate" or WikiPage::READ_LOCKING to get from the primary DB
|
||||
* using SELECT FOR UPDATE.
|
||||
*
|
||||
* @return void
|
||||
|
|
@ -522,8 +522,8 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
|
|||
*
|
||||
* @param string|int $from One of the following:
|
||||
* - "fromdb" or WikiPage::READ_NORMAL to get from a replica DB.
|
||||
* - "fromdbmaster" or WikiPage::READ_LATEST to get from the master DB.
|
||||
* - "forupdate" or WikiPage::READ_LOCKING to get from the master DB
|
||||
* - "fromdbmaster" or WikiPage::READ_LATEST to get from the primary DB.
|
||||
* - "forupdate" or WikiPage::READ_LOCKING to get from the primary DB
|
||||
* using SELECT FOR UPDATE.
|
||||
*
|
||||
* @return bool
|
||||
|
|
@ -550,9 +550,9 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
|
|||
* @param stdClass|bool $data DB row containing fields returned by getQueryInfo() or false
|
||||
* @param string|int $from One of the following:
|
||||
* - "fromdb" or WikiPage::READ_NORMAL if the data comes from a replica DB
|
||||
* - "fromdbmaster" or WikiPage::READ_LATEST if the data comes from the master DB
|
||||
* - "fromdbmaster" or WikiPage::READ_LATEST if the data comes from the primary DB
|
||||
* - "forupdate" or WikiPage::READ_LOCKING if the data comes from
|
||||
* the master DB using SELECT FOR UPDATE
|
||||
* the primary DB using SELECT FOR UPDATE
|
||||
*/
|
||||
public function loadFromRow( $data, $from ) {
|
||||
$lc = MediaWikiServices::getInstance()->getLinkCache();
|
||||
|
|
|
|||
|
|
@ -103,8 +103,8 @@ class WikiPageFactory {
|
|||
* @param stdClass $row Database row containing at least fields returned by getQueryInfo().
|
||||
* @param string|int $from Source of $data:
|
||||
* - "fromdb" or WikiPage::READ_NORMAL: from a replica DB
|
||||
* - "fromdbmaster" or WikiPage::READ_LATEST: from the master DB
|
||||
* - "forupdate" or WikiPage::READ_LOCKING: from the master DB using SELECT FOR UPDATE
|
||||
* - "fromdbmaster" or WikiPage::READ_LATEST: from the primary DB
|
||||
* - "forupdate" or WikiPage::READ_LOCKING: from the primary DB using SELECT FOR UPDATE
|
||||
*
|
||||
* @return WikiPage
|
||||
*/
|
||||
|
|
@ -120,7 +120,7 @@ class WikiPageFactory {
|
|||
* @param int $id Article ID to load
|
||||
* @param string|int $from One of the following values:
|
||||
* - "fromdb" or WikiPage::READ_NORMAL to select from a replica DB
|
||||
* - "fromdbmaster" or WikiPage::READ_LATEST to select from the master database
|
||||
* - "fromdbmaster" or WikiPage::READ_LATEST to select from the primary database
|
||||
*
|
||||
* @return WikiPage|null Null when no page exists with that ID
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ abstract class RevDelList extends RevisionListBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Reload the list data from the master DB. This can be done after setVisibility()
|
||||
* Reload the list data from the primary DB. This can be done after setVisibility()
|
||||
* to allow $item->getHTML() to show the new data.
|
||||
*/
|
||||
public function reloadFromMaster() {
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ class UploadFromChunks extends UploadFromFile {
|
|||
* Get the chunk db state and populate update relevant local values
|
||||
*/
|
||||
private function getChunkStatus() {
|
||||
// get Master db to avoid race conditions.
|
||||
// get primary db to avoid race conditions.
|
||||
// Otherwise, if chunk upload time < replag there will be spurious errors
|
||||
$dbw = $this->repo->getPrimaryDB();
|
||||
$row = $dbw->selectRow(
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ class User implements Authority, UserIdentity, UserEmailContact {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Try cache (unless this needs data from the master DB).
|
||||
// Try cache (unless this needs data from the primary DB).
|
||||
// NOTE: if this thread called saveSettings(), the cache was cleared.
|
||||
$latest = DBAccessObjectUtils::hasFlags( $flags, self::READ_LATEST );
|
||||
if ( $latest ) {
|
||||
|
|
@ -856,7 +856,7 @@ class User implements Authority, UserIdentity, UserEmailContact {
|
|||
$userQuery['joins']
|
||||
);
|
||||
if ( !$row ) {
|
||||
// Try the master database...
|
||||
// Try the primary database...
|
||||
$dbw = $loadBalancer->getConnectionRef( DB_PRIMARY );
|
||||
$row = $dbw->selectRow(
|
||||
$userQuery['tables'],
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class DeleteOrphanedRevisions extends Maintenance {
|
|||
* Do this inside a transaction
|
||||
*
|
||||
* @param int[] $id Array of revision id values
|
||||
* @param IDatabase $dbw Master DB handle
|
||||
* @param IDatabase $dbw Primary DB handle
|
||||
*/
|
||||
private function deleteRevs( array $id, $dbw ) {
|
||||
$dbw->delete( 'revision', [ 'rev_id' => $id ], __METHOD__ );
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ ERROR
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the master DB handle for the current user batch. This is provided for the benefit
|
||||
* Get the primary DB handle for the current user batch. This is provided for the benefit
|
||||
* of authentication extensions which subclass this and work with wiki farms.
|
||||
* @return IMaintainableDatabase
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class InitSiteStats extends Maintenance {
|
|||
$this->addDescription( 'Re-initialise the site statistics tables' );
|
||||
$this->addOption( 'update', 'Update the existing statistics' );
|
||||
$this->addOption( 'active', 'Also update active users count' );
|
||||
$this->addOption( 'use-master', 'Count using the master database' );
|
||||
$this->addOption( 'use-master', 'Count using the primary database' );
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class MysqlMaintenance extends Maintenance {
|
|||
parent::__construct();
|
||||
$this->addDescription( "Execute the MySQL client binary. " .
|
||||
"Non-option arguments will be passed through to mysql." );
|
||||
$this->addOption( 'write', 'Connect to the master database', false, false );
|
||||
$this->addOption( 'write', 'Connect to the primary database', false, false );
|
||||
$this->addOption( 'group', 'Specify query group', false, true );
|
||||
$this->addOption( 'host', 'Connect to a specific MySQL server', false, true );
|
||||
$this->addOption( 'list-hosts', 'List the available DB hosts', false, false );
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Report number of jobs currently waiting in master database.
|
||||
* Report number of jobs currently waiting in primary database.
|
||||
*
|
||||
* Based on runJobs.php
|
||||
*
|
||||
|
|
@ -29,7 +29,7 @@ require_once __DIR__ . '/Maintenance.php';
|
|||
|
||||
/**
|
||||
* Maintenance script that reports the number of jobs currently waiting
|
||||
* in master database.
|
||||
* in the primary database.
|
||||
*
|
||||
* @ingroup Maintenance
|
||||
*/
|
||||
|
|
@ -43,7 +43,7 @@ class ShowJobs extends Maintenance {
|
|||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->addDescription( 'Show number of jobs waiting in master database' );
|
||||
$this->addDescription( 'Show number of jobs waiting in primary database' );
|
||||
$this->addOption( 'group', 'Show number of jobs per job type' );
|
||||
$this->addOption( 'list', 'Show a list of all jobs instead of counts' );
|
||||
$this->addOption( 'type', 'Only show/count jobs of a given type', false, true );
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class MwSql extends Maintenance {
|
|||
$this->addOption( 'wikidb',
|
||||
'The database wiki ID to use if not the current one', false, true );
|
||||
$this->addOption( 'replicadb',
|
||||
'Replica DB server to use instead of the master DB (can be "any")', false, true );
|
||||
'Replica DB server to use instead of the primary DB (can be "any")', false, true );
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class UpdateArticleCount extends Maintenance {
|
|||
parent::__construct();
|
||||
$this->addDescription( 'Count of the number of articles and update the site statistics table' );
|
||||
$this->addOption( 'update', 'Update the site_stats table with the new count' );
|
||||
$this->addOption( 'use-master', 'Count using the master database' );
|
||||
$this->addOption( 'use-master', 'Count using the primary database' );
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
|
|
|
|||
|
|
@ -1564,10 +1564,10 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets master database connections for all of the ExternalStoreDB
|
||||
* Gets primary database connections for all of the ExternalStoreDB
|
||||
* stores configured in $wgDefaultExternalStore.
|
||||
*
|
||||
* @return Database[] Array of Database master connections
|
||||
* @return Database[] Array of Database primary connections
|
||||
*/
|
||||
protected static function getExternalStoreDatabaseConnections() {
|
||||
global $wgDefaultExternalStore;
|
||||
|
|
|
|||
|
|
@ -72,11 +72,11 @@ class RevisionRendererTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
/**
|
||||
* @param int $maxRev
|
||||
* @param bool $useMaster
|
||||
* @param bool $usePrimary
|
||||
* @return RevisionRenderer
|
||||
*/
|
||||
private function newRevisionRenderer( $maxRev = 100, $useMaster = false ) {
|
||||
$dbIndex = $useMaster ? DB_PRIMARY : DB_REPLICA;
|
||||
private function newRevisionRenderer( $maxRev = 100, $usePrimary = false ) {
|
||||
$dbIndex = $usePrimary ? DB_PRIMARY : DB_REPLICA;
|
||||
|
||||
$db = $this->getMockDatabaseConnection( $maxRev );
|
||||
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ class LBFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
$m1Pos = new MySQLMasterPos( 'db1034-bin.000976/843431247', $now );
|
||||
$m2Pos = new MySQLMasterPos( 'db1064-bin.002400/794074907', $now );
|
||||
|
||||
// Master DB 1
|
||||
// Primary DB 1
|
||||
/** @var IDatabase|\PHPUnit\Framework\MockObject\MockObject $mockDB1 */
|
||||
$mockDB1 = $this->getMockBuilder( IDatabase::class )
|
||||
->disableOriginalConstructor()
|
||||
|
|
@ -268,7 +268,7 @@ class LBFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
$mockDB1->method( 'writesOrCallbacksPending' )->willReturn( true );
|
||||
$mockDB1->method( 'lastDoneWrites' )->willReturn( $now );
|
||||
$mockDB1->method( 'getMasterPos' )->willReturn( $m1Pos );
|
||||
// Load balancer for master DB 1
|
||||
// Load balancer for primary DB 1
|
||||
$lb1 = $this->getMockBuilder( LoadBalancer::class )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
|
@ -289,7 +289,7 @@ class LBFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
$lb1->method( 'getMasterPos' )->willReturn( $m1Pos );
|
||||
$lb1->method( 'getReplicaResumePos' )->willReturn( $m1Pos );
|
||||
$lb1->method( 'getServerName' )->with( 0 )->willReturn( 'master1' );
|
||||
// Master DB 2
|
||||
// Primary DB 2
|
||||
/** @var IDatabase|\PHPUnit\Framework\MockObject\MockObject $mockDB2 */
|
||||
$mockDB2 = $this->getMockBuilder( IDatabase::class )
|
||||
->disableOriginalConstructor()
|
||||
|
|
@ -297,7 +297,7 @@ class LBFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
$mockDB2->method( 'writesOrCallbacksPending' )->willReturn( true );
|
||||
$mockDB2->method( 'lastDoneWrites' )->willReturn( $now );
|
||||
$mockDB2->method( 'getMasterPos' )->willReturn( $m2Pos );
|
||||
// Load balancer for master DB 2
|
||||
// Load balancer for primary DB 2
|
||||
$lb2 = $this->getMockBuilder( LoadBalancer::class )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
|
@ -347,7 +347,7 @@ class LBFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
// (b) Second HTTP request
|
||||
|
||||
// Load balancer for master DB 1
|
||||
// Load balancer for primary DB 1
|
||||
$lb1 = $this->getMockBuilder( LoadBalancer::class )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
|
@ -357,7 +357,7 @@ class LBFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
$lb1->method( 'getServerName' )->with( 0 )->willReturn( 'master1' );
|
||||
$lb1->expects( $this->once() )
|
||||
->method( 'waitFor' )->with( $m1Pos );
|
||||
// Load balancer for master DB 2
|
||||
// Load balancer for primary DB 2
|
||||
$lb2 = $this->getMockBuilder( LoadBalancer::class )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ class LoadBalancerTest extends MediaWikiIntegrationTestCase {
|
|||
global $wgDBserver, $wgDBname, $wgDBuser, $wgDBpassword, $wgDBtype, $wgSQLiteDataDir;
|
||||
|
||||
$servers = [
|
||||
// Master DB
|
||||
// Primary DB
|
||||
0 => $srvExtra + [
|
||||
'host' => $wgDBserver,
|
||||
'dbname' => $wgDBname,
|
||||
|
|
@ -774,19 +774,19 @@ class LoadBalancerTest extends MediaWikiIntegrationTestCase {
|
|||
public function testGetLazyConnectionRef() {
|
||||
$lb = $this->newMultiServerLocalLoadBalancer();
|
||||
|
||||
$rMaster = $lb->getLazyConnectionRef( DB_PRIMARY );
|
||||
$rPrimary = $lb->getLazyConnectionRef( DB_PRIMARY );
|
||||
$rReplica = $lb->getLazyConnectionRef( 1 );
|
||||
$this->assertFalse( $lb->getAnyOpenConnection( 0 ) );
|
||||
$this->assertFalse( $lb->getAnyOpenConnection( 1 ) );
|
||||
|
||||
$rMaster->getType();
|
||||
$rPrimary->getType();
|
||||
$rReplica->getType();
|
||||
$rMaster->getDomainID();
|
||||
$rPrimary->getDomainID();
|
||||
$rReplica->getDomainID();
|
||||
$this->assertFalse( $lb->getAnyOpenConnection( 0 ) );
|
||||
$this->assertFalse( $lb->getAnyOpenConnection( 1 ) );
|
||||
|
||||
$rMaster->query( "SELECT 1", __METHOD__ );
|
||||
$rPrimary->query( "SELECT 1", __METHOD__ );
|
||||
$this->assertNotFalse( $lb->getAnyOpenConnection( 0 ) );
|
||||
|
||||
$rReplica->query( "SELECT 1", __METHOD__ );
|
||||
|
|
|
|||
Loading…
Reference in a new issue