aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames D. Forrester <jforrester@wikimedia.org>2021-04-18 18:02:08 -0700
committerJames D. Forrester <jforrester@wikimedia.org>2021-05-14 12:40:34 -0700
commitf2f9345e39d4169d387c198eececb112761b338a (patch)
treef75761bb45fd4be7a08126ae82c562fc7a422c57
parent0157586f9b311751b3ebb06e41ddfd2afd254ebe (diff)
downloadmediawikicore-f2f9345e39d4169d387c198eececb112761b338a.tar.gz
mediawikicore-f2f9345e39d4169d387c198eececb112761b338a.zip
Replace uses of DB_MASTER with DB_PRIMARY in documentation and local variables
This is just a start. Bug: T254646 Change-Id: I9213aad4660e27afe7ff9e5d2e730cbf03911068
-rw-r--r--docs/database.md24
-rw-r--r--includes/DefaultSettings.php18
-rw-r--r--includes/EditPage.php2
-rw-r--r--includes/GlobalFunctions.php4
-rw-r--r--includes/MediaWiki.php2
-rw-r--r--includes/Pingback.php6
-rw-r--r--includes/Revision.php16
-rw-r--r--includes/Revision/RevisionStore.php2
-rw-r--r--includes/SiteStatsInit.php4
-rw-r--r--includes/Storage/NameTableStore.php4
-rw-r--r--includes/Storage/PageUpdater.php2
-rw-r--r--includes/Storage/SqlBlobStore.php4
-rw-r--r--includes/Title.php6
-rw-r--r--includes/api/ApiBase.php6
-rw-r--r--includes/api/ApiOptions.php2
-rw-r--r--includes/auth/AuthManager.php2
-rw-r--r--includes/block/BlockManager.php16
-rw-r--r--includes/block/DatabaseBlock.php28
-rw-r--r--includes/cache/MessageCache.php2
-rw-r--r--includes/changetags/ChangeTagsList.php2
-rw-r--r--includes/content/ContentHandler.php4
-rw-r--r--includes/dao/DBAccessObjectUtils.php6
-rw-r--r--includes/dao/IDBAccessObject.php12
-rw-r--r--includes/deferred/UserEditCountUpdate.php2
-rw-r--r--includes/externalstore/ExternalStoreDB.php10
-rw-r--r--includes/filerepo/LocalRepo.php4
-rw-r--r--includes/jobqueue/JobQueueDB.php2
-rw-r--r--includes/jobqueue/jobs/RefreshLinksJob.php4
-rw-r--r--includes/libs/rdbms/database/DBConnRef.php12
-rw-r--r--includes/libs/rdbms/loadbalancer/ILoadBalancer.php96
-rw-r--r--includes/libs/rdbms/loadbalancer/LoadBalancer.php12
-rw-r--r--includes/page/PageStore.php2
-rw-r--r--includes/user/BotPassword.php2
-rw-r--r--includes/watcheditem/WatchedItemStore.php2
-rw-r--r--maintenance/includes/Maintenance.php2
35 files changed, 162 insertions, 162 deletions
diff --git a/docs/database.md b/docs/database.md
index 30bbaf8976ab..cb893a1d43d2 100644
--- a/docs/database.md
+++ b/docs/database.md
@@ -24,10 +24,10 @@ foreach ( $res as $row ) {
For a write query, use something like:
```php
-$dbw = wfGetDB( DB_MASTER );
+$dbw = wfGetDB( DB_PRIMARY );
$dbw->insert( /* ...see docs... */ );
```
-We use the convention `$dbr` for read and `$dbw` for write to help you keep track of whether the database object is a replica (read-only) or a master (read/write). If you write to a replica, the world will explode. Or to be precise, a subsequent write query which succeeded on the master may fail when propagated to the replica due to a unique key collision. Replication will then stop and it may take hours to repair the database and get it back online. Setting `read_only` in `my.cnf` on the replica will avoid this scenario, but given the dire consequences, we prefer to have as many checks as possible.
+We use the convention `$dbr` for read and `$dbw` for write to help you keep track of whether the database object is a replica (read-only) or a primary (read/write). If you write to a replica, the world will explode. Or to be precise, a subsequent write query which succeeded on the primary may fail when propagated to the replica due to a unique key collision. Replication will then stop and it may take hours to repair the database and get it back online. Setting `read_only` in `my.cnf` on the replica will avoid this scenario, but given the dire consequences, we prefer to have as many checks as possible.
We provide a `query()` function for raw SQL, but the wrapper functions like `select()` and `insert()` are usually more convenient. They take care of things like table prefixes and escaping for you. If you really need to make your own SQL, please read the documentation for `tableName()` and `addQuotes()`. You will need both of them.
@@ -38,19 +38,19 @@ MediaWiki developers who need to write DB queries should have some understanding
## Replication
-The largest installation of MediaWiki, Wikimedia, uses a large set of replica MySQL servers replicating writes made to a master MySQL server. It is important to understand the issues associated with this setup if you want to write code destined for Wikipedia.
+The largest installation of MediaWiki, Wikimedia, uses a large set of replica MySQL servers replicating writes made to a primary MySQL server. It is important to understand the issues associated with this setup if you want to write code destined for Wikipedia.
It's often the case that the best algorithm to use for a given task depends on whether or not replication is in use. Due to our unabashed Wikipedia-centrism, we often just use the replication-friendly version, but if you like, you can use `LoadBalancer::getServerCount() > 1` to check to see if replication is in use.
## Lag
-Lag primarily occurs when large write queries are sent to the master. Writes on the master are executed in parallel, but they are executed in serial when they are replicated to the replicas. The master writes the query to the binlog when the transaction is committed. The replicas poll the binlog and start executing the query as soon as it appears. They can service reads while they are performing a write query, but will not read anything more from the binlog and thus will perform no more writes. This means that if the write query runs for a long time, the replicas will lag behind the master for the time it takes for the write query to complete.
+Lag primarily occurs when large write queries are sent to the primary. Writes on the primary are executed in parallel, but they are executed in serial when they are replicated to the replicas. The primary writes the query to the binlog when the transaction is committed. The replicas poll the binlog and start executing the query as soon as it appears. They can service reads while they are performing a write query, but will not read anything more from the binlog and thus will perform no more writes. This means that if the write query runs for a long time, the replicas will lag behind the primary for the time it takes for the write query to complete.
Lag can be exacerbated by high read load. MediaWiki's load balancer will stop sending reads to a replica when it is lagged by more than 30 seconds. If the load ratios are set incorrectly, or if there is too much load generally, this may lead to a replica permanently hovering around 30 seconds lag.
If all replicas are lagged by more than 30 seconds, MediaWiki will stop writing to the database. All edits and other write operations will be refused, with an error returned to the user. This gives the replicas a chance to catch up. Before we had this mechanism, the replicas would regularly lag by several minutes, making review of recent edits difficult.
-In addition to this, MediaWiki attempts to ensure that the user sees events occurring on the wiki in chronological order. A few seconds of lag can be tolerated, as long as the user sees a consistent picture from subsequent requests. This is done by saving the master binlog position in the session, and then at the start of each request, waiting for the replica to catch up to that position before doing any reads from it. If this wait times out, reads are allowed anyway, but the request is considered to be in "lagged replica mode". Lagged replica mode can be checked by calling `LoadBalancer::getLaggedReplicaMode()`. The only practical consequence at present is a warning displayed in the page footer.
+In addition to this, MediaWiki attempts to ensure that the user sees events occurring on the wiki in chronological order. A few seconds of lag can be tolerated, as long as the user sees a consistent picture from subsequent requests. This is done by saving the primary binlog position in the session, and then at the start of each request, waiting for the replica to catch up to that position before doing any reads from it. If this wait times out, reads are allowed anyway, but the request is considered to be in "lagged replica mode". Lagged replica mode can be checked by calling `LoadBalancer::getLaggedReplicaMode()`. The only practical consequence at present is a warning displayed in the page footer.
## Lag avoidance
@@ -58,14 +58,14 @@ To avoid excessive lag, queries which write large numbers of rows should be spli
## Working with lag
-Despite our best efforts, it's not practical to guarantee a low-lag environment. Lag will usually be less than one second, but may occasionally be up to 30 seconds. For scalability, it's very important to keep load on the master low, so simply sending all your queries to the master is not the answer. So when you have a genuine need for up-to-date data, the following approach is advised:
+Despite our best efforts, it's not practical to guarantee a low-lag environment. Lag will usually be less than one second, but may occasionally be up to 30 seconds. For scalability, it's very important to keep load on the primary low, so simply sending all your queries to the masprimaryter is not the answer. So when you have a genuine need for up-to-date data, the following approach is advised:
-1) Do a quick query to the master for a sequence number or timestamp
+1) Do a quick query to the primary for a sequence number or timestamp
2) Run the full query on the replica and check if it matches the data you got
-from the master
-3) If it doesn't, run the full query on the master
+from the primary
+3) If it doesn't, run the full query on the primary
-To avoid swamping the master every time the replicas lag, use of this approach should be kept to a minimum. In most cases you should just read from the replica and let the user deal with the delay.
+To avoid swamping the primary every time the replicas lag, use of this approach should be kept to a minimum. In most cases you should just read from the replica and let the user deal with the delay.
## Lock contention
@@ -74,7 +74,7 @@ Due to the high write rate on Wikipedia (and some other wikis), MediaWiki develo
Often this approach is not good enough, and it becomes necessary to enclose small groups of queries in their own transaction. Use the following syntax:
```php
-$dbw = wfGetDB( DB_MASTER );
+$dbw = wfGetDB( DB_PRIMARY );
$dbw->begin( __METHOD__ );
/* Do queries */
$dbw->commit( __METHOD__ );
@@ -86,7 +86,7 @@ Instead of locking reads, combine your existence checks into your write queries,
## Query groups
-MediaWiki supports database query groups, a way to indicate a preferred group of database hosts to use for a given query. Query groups are only supported for connections to child (non-master) databases, making them only viable for read operations. It should be noted that using query groups does not _guarantee_ a given group of hosts will be used, but rather that the query prefers such group. Making use of query groups can be benficial in many cases.
+MediaWiki supports database query groups, a way to indicate a preferred group of database hosts to use for a given query. Query groups are only supported for connections to child (non-primary) databases, making them only viable for read operations. It should be noted that using query groups does not _guarantee_ a given group of hosts will be used, but rather that the query prefers such group. Making use of query groups can be benficial in many cases.
One benefit is a reduction of cache misses. Directing reads for a category of queries (e.g. all logging queries) to a given host can result in more deterministic and faster performing queries.
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 56bf17e8b8ca..78d011e58e02 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -2252,7 +2252,7 @@ $wgSharedSchema = false;
* variable, the single-server variables will generally be ignored (except
* perhaps in some command-line scripts).
*
- * The first server listed in this array (with key 0) will be the master. The
+ * The first server listed in this array (with key 0) will be the primary. The
* rest of the servers will be replica DBs. To prevent writes to your replica DBs due to
* accidental misconfiguration or MediaWiki bugs, set read_only=1 on all your
* replica DBs in my.cnf. You can set read_only mode at runtime using:
@@ -2263,14 +2263,14 @@ $wgSharedSchema = false;
*
* Since the effect of writing to a replica DB is so damaging and difficult to clean
* up, we at Wikimedia set read_only=1 in my.cnf on all our DB servers, even
- * our masters, and then set read_only=0 on masters at runtime.
+ * our primaries, and then set read_only=0 on primaries at runtime.
*/
$wgDBservers = false;
/**
* Load balancer factory configuration
- * To set up a multi-master wiki farm, set the class here to something that
- * can return a LoadBalancer with an appropriate master on a call to getMainLB().
+ * To set up a multi-primary wiki farm, set the class here to something that
+ * can return a LoadBalancer with an appropriate primary on a call to getMainLB().
* The class identified here is responsible for reading $wgDBservers,
* $wgDBserver, etc., so overriding it may cause those globals to be ignored.
*
@@ -2281,7 +2281,7 @@ $wgLBFactoryConf = [ 'class' => \Wikimedia\Rdbms\LBFactorySimple::class ];
/**
* After a state-changing request is done by a client, this determines
- * how many seconds that client should keep using the master datacenter.
+ * how many seconds that client should keep using the primary datacenter.
* This avoids unexpected stale or 404 responses due to replication lag.
*
* This must be greater than or equal to
@@ -2883,7 +2883,7 @@ $wgEnableWANCacheReaper = false;
* system for these operations.
*
* The multi-datacenter strategy for MediaWiki is to have CDN route HTTP POST requests to the
- * master datacenter and HTTP GET/HEAD/OPTIONS requests to the closest datacenter to the client.
+ * primary datacenter and HTTP GET/HEAD/OPTIONS requests to the closest datacenter to the client.
* The stash accepts write operations from any datacenter, but cross-datacenter replication is
* asynchronous.
*
@@ -7240,7 +7240,7 @@ $wgDebugDumpSql = false;
*/
$wgTrxProfilerLimits = [
// HTTP GET/HEAD requests.
- // Master queries should not happen on GET requests
+ // Primary queries should not happen on GET requests
'GET' => [
'masterConns' => 0,
'writes' => 0,
@@ -7248,7 +7248,7 @@ $wgTrxProfilerLimits = [
'readQueryRows' => 10000
],
// HTTP POST requests.
- // Master reads and writes will happen for a subset of these.
+ // Primary reads and writes will happen for a subset of these.
'POST' => [
'readQueryTime' => 5,
'writeQueryTime' => 1,
@@ -7266,7 +7266,7 @@ $wgTrxProfilerLimits = [
'writeQueryTime' => 1,
'readQueryRows' => 10000,
'maxAffected' => 1000,
- // Log master queries under the post-send entry point as they are discouraged
+ // Log primary queries under the post-send entry point as they are discouraged
'masterConns' => 0,
'writes' => 0,
],
diff --git a/includes/EditPage.php b/includes/EditPage.php
index d20a1e9c17c3..f1ccb146c1cf 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -2058,7 +2058,7 @@ class EditPage implements IEditObject {
}
// END OF MIGRATION TO EDITCONSTRAINT SYSTEM (continued below)
- # Load the page data from the master. If anything changes in the meantime,
+ # Load the page data from the primary DB. If anything changes in the meantime,
# we detect it by using page_latest like a token in a 1 try compare-and-swap.
$this->page->loadPageData( 'fromdbmaster' );
$new = !$this->page->exists();
diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index 273f2d23edd3..108291d254de 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -2275,8 +2275,8 @@ function wfWikiID() {
/**
* Get a Database object.
*
- * @param int $db Index of the connection to get. May be DB_MASTER for the
- * master (for write queries), DB_REPLICA for potentially lagged read
+ * @param int $db Index of the connection to get. May be DB_PRIMARY for the
+ * primary (for write queries), DB_REPLICA for potentially lagged read
* queries, or an integer >= 0 for a particular server.
*
* @param string|string[] $groups Query groups. An array of group names that this query
diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php
index 9ab3def786f3..6ff5fbb60397 100644
--- a/includes/MediaWiki.php
+++ b/includes/MediaWiki.php
@@ -734,7 +734,7 @@ class MediaWiki {
if ( $allowHeaders ) {
// Set a cookie to tell all CDN edge nodes to "stick" the user to the DC that
- // handles this POST request (e.g. the "master" data center). Also have the user
+ // handles this POST request (e.g. the "primary" data center). Also have the user
// briefly bypass CDN so ChronologyProtector works for cacheable URLs.
if ( $request->wasPosted() && $lbFactory->hasOrMadeRecentMasterChanges() ) {
$expires = $now + max(
diff --git a/includes/Pingback.php b/includes/Pingback.php
index 51d1d9e07c0a..0d6769303766 100644
--- a/includes/Pingback.php
+++ b/includes/Pingback.php
@@ -219,7 +219,7 @@ class Pingback {
* @return string 32-character hex string
*/
private function fetchOrInsertId() : string {
- // We've already obtained a master connection for the lock, and plan to do a write.
+ // We've already obtained a primary connection for the lock, and plan to do a write.
// But, still prefer reading this immutable value from a replica to reduce load.
$dbr = $this->lb->getConnectionRef( DB_REPLICA );
$id = $dbr->selectField( 'updatelog', 'ul_value', [ 'ul_key' => 'PingBack' ], __METHOD__ );
@@ -292,9 +292,9 @@ class Pingback {
if ( !$config->get( 'Pingback' ) ) {
// Fault tolerance:
// Pingback is unusual. On a plain install of MediaWiki, it is likely the only
- // feature making use of DeferredUpdates and DB_MASTER on most page views.
+ // feature making use of DeferredUpdates and DB_PRIMARY on most page views.
// In order for the wiki to remain available and readable even if DeferredUpdates
- // or DB_MASTER have issues, allow this to be turned off completely. (T269516)
+ // or DB_PRIMARY have issues, allow this to be turned off completely. (T269516)
return;
}
DeferredUpdates::addCallableUpdate( static function () {
diff --git a/includes/Revision.php b/includes/Revision.php
index 5441eab34eb9..5cd83f4a3bf4 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -111,8 +111,8 @@ class Revision implements IDBAccessObject {
* @deprecated since 1.31 together with the class. Hard deprecated since 1.35
*
* $flags include:
- * Revision::READ_LATEST : Select the data from the master
- * Revision::READ_LOCKING : Select & lock the data from the master
+ * Revision::READ_LATEST : Select the data from the primary
+ * Revision::READ_LOCKING : Select & lock the data from the primary
*
* @param int $id
* @param int $flags (optional)
@@ -132,8 +132,8 @@ class Revision implements IDBAccessObject {
* @deprecated since 1.31 together with the class. Hard deprecated since 1.35
*
* $flags include:
- * Revision::READ_LATEST : Select the data from the master
- * Revision::READ_LOCKING : Select & lock the data from the master
+ * Revision::READ_LATEST : Select the data from the primary
+ * Revision::READ_LOCKING : Select & lock the data from the primary
*
* @param LinkTarget $linkTarget
* @param int $id (optional)
@@ -152,8 +152,8 @@ class Revision implements IDBAccessObject {
* Returns null if no such revision can be found.
*
* $flags include:
- * Revision::READ_LATEST : Select the data from the master (since 1.20)
- * Revision::READ_LOCKING : Select & lock the data from the master
+ * Revision::READ_LATEST : Select the data from the primary (since 1.20)
+ * Revision::READ_LOCKING : Select & lock the data from the primary
*
* @deprecated since 1.31 together with the class. Hard deprecated since 1.35
*
@@ -720,7 +720,7 @@ class Revision implements IDBAccessObject {
* @deprecated since 1.31 (soft), 1.35 (hard)
*
* @param int $flags (optional) $flags include:
- * Revision::READ_LATEST : Select the data from the master
+ * Revision::READ_LATEST : Select the data from the primary
*
* @since 1.22
* @return RecentChange|null
@@ -1002,7 +1002,7 @@ class Revision implements IDBAccessObject {
*
* @deprecated since 1.31 (soft), 1.35 (hard)
*
- * @param IDatabase $dbw (master connection)
+ * @param IDatabase $dbw (primary connection)
* @throws MWException
* @return int The revision ID
*/
diff --git a/includes/Revision/RevisionStore.php b/includes/Revision/RevisionStore.php
index 30c846480366..125828865a43 100644
--- a/includes/Revision/RevisionStore.php
+++ b/includes/Revision/RevisionStore.php
@@ -259,7 +259,7 @@ class RevisionStore
}
/**
- * @param int $mode DB_MASTER or DB_REPLICA
+ * @param int $mode DB_PRIMARY or DB_REPLICA
*
* @param array $groups
* @return DBConnRef
diff --git a/includes/SiteStatsInit.php b/includes/SiteStatsInit.php
index 58616200a2db..1e8f90a349e3 100644
--- a/includes/SiteStatsInit.php
+++ b/includes/SiteStatsInit.php
@@ -39,7 +39,7 @@ class SiteStatsInit {
/**
* @param bool|IDatabase $database
- * - bool: Whether to use the master DB
+ * - bool: Whether to use the primary DB
* - IDatabase: Database connection to use
*/
public function __construct( $database = false ) {
@@ -126,7 +126,7 @@ class SiteStatsInit {
* for the original initStats, but without output.
*
* @param IDatabase|bool $database
- * - bool: Whether to use the master DB
+ * - bool: Whether to use the primary DB
* - IDatabase: Database connection to use
* @param array $options Array of options, may contain the following values
* - activeUsers bool: Whether to update the number of active users (default: false)
diff --git a/includes/Storage/NameTableStore.php b/includes/Storage/NameTableStore.php
index 782bc46190c9..b7bc5d11d978 100644
--- a/includes/Storage/NameTableStore.php
+++ b/includes/Storage/NameTableStore.php
@@ -106,7 +106,7 @@ class NameTableStore {
}
/**
- * @param int $index A database index, like DB_MASTER or DB_REPLICA
+ * @param int $index A database index, like DB_PRIMARY or DB_REPLICA
* @param int $flags Database connection flags
*
* @return IDatabase
@@ -174,7 +174,7 @@ class NameTableStore {
$searchResult = array_search( $name, $table, true );
if ( $searchResult === false ) {
- // Insert failed due to IGNORE flag, but DB_MASTER didn't give us the data
+ // Insert failed due to IGNORE flag, but DB_PRIMARY didn't give us the data
$m = "No insert possible but master didn't give us a record for " .
"'{$name}' in '{$this->table}'";
$this->logger->error( $m );
diff --git a/includes/Storage/PageUpdater.php b/includes/Storage/PageUpdater.php
index dd52bbc24bc7..faab63550cc4 100644
--- a/includes/Storage/PageUpdater.php
+++ b/includes/Storage/PageUpdater.php
@@ -300,7 +300,7 @@ class PageUpdater {
}
/**
- * @param int $mode DB_MASTER or DB_REPLICA
+ * @param int $mode DB_PRIMARY or DB_REPLICA
*
* @return DBConnRef
*/
diff --git a/includes/Storage/SqlBlobStore.php b/includes/Storage/SqlBlobStore.php
index 51e762523ca4..3d4ebd470288 100644
--- a/includes/Storage/SqlBlobStore.php
+++ b/includes/Storage/SqlBlobStore.php
@@ -201,7 +201,7 @@ class SqlBlobStore implements IDBAccessObject, BlobStore {
}
/**
- * @param int $index A database index, like DB_MASTER or DB_REPLICA
+ * @param int $index A database index, like DB_PRIMARY or DB_REPLICA
*
* @return IDatabase
*/
@@ -403,7 +403,7 @@ class SqlBlobStore implements IDBAccessObject, BlobStore {
$options
);
- // Fallback to DB_MASTER in some cases if not all the rows were found, using the appropriate
+ // Fallback to DB_PRIMARY in some cases if not all the rows were found, using the appropriate
// options, such as FOR UPDATE to avoid missing rows due to REPEATABLE-READ.
if ( $dbConnection->numRows( $rows ) !== count( $textIds ) && $fallbackIndex !== null ) {
$fetchedTextIds = [];
diff --git a/includes/Title.php b/includes/Title.php
index 2659878e09b9..56155a288b12 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -61,7 +61,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
/**
* Used to be GAID_FOR_UPDATE define(). Used with getArticleID() and friends
- * to use the master DB and inject it into link cache.
+ * to use the primary DB and inject it into link cache.
* @deprecated since 1.34, use Title::READ_LATEST instead.
*/
public const GAID_FOR_UPDATE = 512;
@@ -2837,7 +2837,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
public function loadRestrictionsFromRows( $rows, $oldFashionedRestrictions = null ) {
// This function will only read rows from a table that we migrated away
// from before adding READ_LATEST support to loadRestrictions, so we
- // don't need to support reading from DB_MASTER here.
+ // don't need to support reading from DB_PRIMARY here.
$dbr = wfGetDB( DB_REPLICA );
$restrictionTypes = $this->getRestrictionTypes();
@@ -2910,7 +2910,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
* Edit and move sections are separated by a colon
* Example: "edit=autoconfirmed,sysop:move=sysop"
* @param int $flags A bit field. If self::READ_LATEST is set, skip replicas and read
- * from the master DB.
+ * from the primary DB.
*/
public function loadRestrictions( $oldFashionedRestrictions = null, $flags = 0 ) {
$readLatest = DBAccessObjectUtils::hasFlags( $flags, self::READ_LATEST );
diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php
index 06eb655e25fe..bcf8a1fe214f 100644
--- a/includes/api/ApiBase.php
+++ b/includes/api/ApiBase.php
@@ -331,8 +331,8 @@ abstract class ApiBase extends ContextSource {
* Indicates whether this module requires write mode
*
* This should return true for modules 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.
* Additionally, requests that only need replica DBs can be efficiently routed to any
* datacenter via the Promise-Non-Write-API-Action header.
*
@@ -981,7 +981,7 @@ abstract class ApiBase extends ContextSource {
* @param string|false $load Whether load the object's state from the database:
* - false: don't load (if the pageid is given, it will still be loaded)
* - 'fromdb': load from a replica DB
- * - 'fromdbmaster': load from the master database
+ * - 'fromdbmaster': load from the primary database
* @return WikiPage
*/
public function getTitleOrPageId( $params, $load = false ) {
diff --git a/includes/api/ApiOptions.php b/includes/api/ApiOptions.php
index ae55bad578ce..f88822beb7ae 100644
--- a/includes/api/ApiOptions.php
+++ b/includes/api/ApiOptions.php
@@ -178,7 +178,7 @@ class ApiOptions extends ApiBase {
}
/**
- * Load the user from the master to reduce CAS errors on double post (T95839)
+ * Load the user from the primary to reduce CAS errors on double post (T95839)
*
* @return User|null
*/
diff --git a/includes/auth/AuthManager.php b/includes/auth/AuthManager.php
index 4a1026435683..252ea1172c72 100644
--- a/includes/auth/AuthManager.php
+++ b/includes/auth/AuthManager.php
@@ -1604,7 +1604,7 @@ class AuthManager implements LoggerAwareInterface {
$localId = User::idFromName( $username );
$flags = User::READ_NORMAL;
- // Fetch the user ID from the master, so that we don't try to create the user
+ // Fetch the user ID from the primary, so that we don't try to create the user
// when they already exist, due to replication lag
// @codeCoverageIgnoreStart
if (
diff --git a/includes/block/BlockManager.php b/includes/block/BlockManager.php
index e32d2fcf0cad..e8c11a1addef 100644
--- a/includes/block/BlockManager.php
+++ b/includes/block/BlockManager.php
@@ -117,13 +117,13 @@ class BlockManager {
* information from the request header are needed to find some types of blocks.
* @param bool $fromReplica Whether to check the replica DB first.
* To improve performance, non-critical checks are done against replica DBs.
- * Check when actually saving should be done against master.
+ * Check when actually saving should be done against primary.
* @param bool $disableIpBlockExemptChecking This is used internally to prevent
* a infinite recursion with autopromote. See T270145.
* @return AbstractBlock|null The most relevant block, or null if there is no block.
*/
public function getUserBlock( User $user, $request, $fromReplica, $disableIpBlockExemptChecking = false ) {
- $fromMaster = !$fromReplica;
+ $fromPrimary = !$fromReplica;
$ip = null;
// If this is the global user, they may be affected by IP blocks (case #1),
@@ -142,8 +142,8 @@ class BlockManager {
// Case #1: checking the global user, including IP blocks
$ip = $request->getIP();
// TODO: remove dependency on DatabaseBlock (T221075)
- $blocks = DatabaseBlock::newListFromTarget( $user, $ip, $fromMaster );
- $this->getAdditionalIpBlocks( $blocks, $request, !$user->isRegistered(), $fromMaster );
+ $blocks = DatabaseBlock::newListFromTarget( $user, $ip, $fromPrimary );
+ $this->getAdditionalIpBlocks( $blocks, $request, !$user->isRegistered(), $fromPrimary );
$this->getCookieBlock( $blocks, $user, $request );
} else {
@@ -152,7 +152,7 @@ class BlockManager {
// and cookie blocks, so we only check for a user account block.
// Case #3: checking whether another user's account is blocked.
// TODO: remove dependency on DatabaseBlock (T221075)
- $blocks = DatabaseBlock::newListFromTarget( $user, null, $fromMaster );
+ $blocks = DatabaseBlock::newListFromTarget( $user, null, $fromPrimary );
}
@@ -198,10 +198,10 @@ class BlockManager {
* @param AbstractBlock[] &$blocks Blocks found so far
* @param WebRequest $request
* @param bool $isAnon The user is logged out
- * @param bool $fromMaster
+ * @param bool $fromPrimary
* @return void
*/
- private function getAdditionalIpBlocks( &$blocks, WebRequest $request, $isAnon, $fromMaster ) {
+ private function getAdditionalIpBlocks( &$blocks, WebRequest $request, $isAnon, $fromPrimary ) {
$ip = $request->getIP();
// Proxy blocking
@@ -241,7 +241,7 @@ class BlockManager {
$xff = array_map( 'trim', explode( ',', $xff ) );
$xff = array_diff( $xff, [ $ip ] );
// TODO: remove dependency on DatabaseBlock (T221075)
- $xffblocks = DatabaseBlock::getBlocksForIPList( $xff, $isAnon, $fromMaster );
+ $xffblocks = DatabaseBlock::getBlocksForIPList( $xff, $isAnon, $fromPrimary );
$blocks = array_merge( $blocks, $xffblocks );
}
}
diff --git a/includes/block/DatabaseBlock.php b/includes/block/DatabaseBlock.php
index 761aa836ecea..b7269f722c88 100644
--- a/includes/block/DatabaseBlock.php
+++ b/includes/block/DatabaseBlock.php
@@ -66,7 +66,7 @@ class DatabaseBlock extends AbstractBlock {
private $mId;
/** @var bool */
- private $mFromMaster;
+ private $mFromPrimary;
/** @var int Hack for foreign blocking (CentralAuth) */
private $forcedTargetID;
@@ -161,7 +161,7 @@ class DatabaseBlock extends AbstractBlock {
$this->isCreateAccountBlocked( (bool)$options['createAccount'] );
$this->isUsertalkEditAllowed( (bool)$options['allowUsertalk'] );
- $this->mFromMaster = false;
+ $this->mFromPrimary = false;
}
/**
@@ -268,7 +268,7 @@ class DatabaseBlock extends AbstractBlock {
*
* @param UserIdentity|string|null $specificTarget
* @param int|null $specificType
- * @param bool $fromMaster
+ * @param bool $fromPrimary
* @param UserIdentity|string|null $vagueTarget Also search for blocks affecting this target.
* Doesn't make any sense to use TYPE_AUTO / TYPE_ID here. Leave blank to skip IP lookups.
* @throws MWException
@@ -277,10 +277,10 @@ class DatabaseBlock extends AbstractBlock {
protected static function newLoad(
$specificTarget,
$specificType,
- $fromMaster,
+ $fromPrimary,
$vagueTarget = null
) {
- $db = wfGetDB( $fromMaster ? DB_PRIMARY : DB_REPLICA );
+ $db = wfGetDB( $fromPrimary ? DB_PRIMARY : DB_REPLICA );
if ( $specificType !== null ) {
$conds = [ 'ipb_address' => [ (string)$specificTarget ] ];
@@ -894,13 +894,13 @@ class DatabaseBlock extends AbstractBlock {
* @param string|UserIdentity|int|null $vagueTarget As above, but we will search for *any* block which
* affects that target (so for an IP address, get ranges containing that IP; and also
* get any relevant autoblocks). Leave empty or blank to skip IP-based lookups.
- * @param bool $fromMaster Whether to use the DB_MASTER database
+ * @param bool $fromPrimary Whether to use the DB_PRIMARY database
* @return DatabaseBlock|null (null if no relevant block could be found). The target and type
* of the returned block will refer to the actual block which was found, which might
* not be the same as the target you gave if you used $vagueTarget!
*/
- public static function newFromTarget( $specificTarget, $vagueTarget = null, $fromMaster = false ) {
- $blocks = self::newListFromTarget( $specificTarget, $vagueTarget, $fromMaster );
+ public static function newFromTarget( $specificTarget, $vagueTarget = null, $fromPrimary = false ) {
+ $blocks = self::newListFromTarget( $specificTarget, $vagueTarget, $fromPrimary );
return self::chooseMostSpecificBlock( $blocks );
}
@@ -910,13 +910,13 @@ class DatabaseBlock extends AbstractBlock {
* @since 1.34
* @param string|UserIdentity|int|null $specificTarget
* @param string|UserIdentity|int|null $vagueTarget
- * @param bool $fromMaster
+ * @param bool $fromPrimary
* @return DatabaseBlock[] Any relevant blocks
*/
public static function newListFromTarget(
$specificTarget,
$vagueTarget = null,
- $fromMaster = false
+ $fromPrimary = false
) {
list( $target, $type ) = MediaWikiServices::getInstance()
->getBlockUtils()
@@ -933,7 +933,7 @@ class DatabaseBlock extends AbstractBlock {
$type,
[ self::TYPE_USER, self::TYPE_IP, self::TYPE_RANGE, null ] )
) {
- return self::newLoad( $target, $type, $fromMaster, $vagueTarget );
+ return self::newLoad( $target, $type, $fromPrimary, $vagueTarget );
}
return [];
}
@@ -944,11 +944,11 @@ class DatabaseBlock extends AbstractBlock {
* @param array $ipChain List of IPs (strings), usually retrieved from the
* X-Forwarded-For header of the request
* @param bool $isAnon Exclude anonymous-only blocks if false
- * @param bool $fromMaster Whether to query the master or replica DB
+ * @param bool $fromPrimary Whether to query the primary or replica DB
* @return self[]
* @since 1.22
*/
- public static function getBlocksForIPList( array $ipChain, $isAnon, $fromMaster = false ) {
+ public static function getBlocksForIPList( array $ipChain, $isAnon, $fromPrimary = false ) {
if ( $ipChain === [] ) {
return [];
}
@@ -978,7 +978,7 @@ class DatabaseBlock extends AbstractBlock {
return [];
}
- if ( $fromMaster ) {
+ if ( $fromPrimary ) {
$db = wfGetDB( DB_PRIMARY );
} else {
$db = wfGetDB( DB_REPLICA );
diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php
index d2e257e4e7f0..fdeb3c0e1110 100644
--- a/includes/cache/MessageCache.php
+++ b/includes/cache/MessageCache.php
@@ -421,7 +421,7 @@ class MessageCache implements LoggerAwareInterface {
/**
* @param string $code
* @param string[] &$where List of debug comments
- * @param int|null $mode Use MessageCache::FOR_UPDATE to use DB_MASTER
+ * @param int|null $mode Use MessageCache::FOR_UPDATE to use DB_PRIMARY
* @return true|string True on success or one of ("cantacquire", "disabled")
*/
protected function loadFromDBWithLock( $code, array &$where, $mode = null ) {
diff --git a/includes/changetags/ChangeTagsList.php b/includes/changetags/ChangeTagsList.php
index 146be5bee1f9..952b70a16b29 100644
--- a/includes/changetags/ChangeTagsList.php
+++ b/includes/changetags/ChangeTagsList.php
@@ -63,7 +63,7 @@ abstract class ChangeTagsList extends RevisionListBase {
}
/**
- * Reload the list data from the master DB.
+ * Reload the list data from the primary DB.
*/
public function reloadFromMaster() {
$dbw = wfGetDB( DB_PRIMARY );
diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php
index f2078e8f95ca..12e644818e2a 100644
--- a/includes/content/ContentHandler.php
+++ b/includes/content/ContentHandler.php
@@ -1424,7 +1424,7 @@ abstract class ContentHandler {
/**
* Get the latest revision of the given $page,
- * fetching it from the master if necessary.
+ * fetching it from the primary if necessary.
*
* @param WikiPage $page
* @return RevisionRecord
@@ -1434,7 +1434,7 @@ abstract class ContentHandler {
$revRecord = $page->getRevisionRecord();
if ( $revRecord == null ) {
// If the content represents a brand new page it's possible
- // we need to fetch it from the master.
+ // we need to fetch it from the primary.
$page->loadPageData( WikiPage::READ_LATEST );
$revRecord = $page->getRevisionRecord();
if ( $revRecord == null ) {
diff --git a/includes/dao/DBAccessObjectUtils.php b/includes/dao/DBAccessObjectUtils.php
index 7a9c4e1000b9..fe12366e3116 100644
--- a/includes/dao/DBAccessObjectUtils.php
+++ b/includes/dao/DBAccessObjectUtils.php
@@ -40,13 +40,13 @@ class DBAccessObjectUtils implements IDBAccessObject {
* Get an appropriate DB index, options, and fallback DB index for a query
*
* The fallback DB index and options are to be used if the entity is not found
- * with the initial DB index, typically querying the master DB to avoid lag
+ * with the initial DB index, typically querying the primary DB to avoid lag
*
* @param int $bitfield Bitfield of IDBAccessObject::READ_* constants
* @return array List of DB indexes and options in this order:
- * - DB_MASTER or DB_REPLICA constant for the initial query
+ * - DB_PRIMARY or DB_REPLICA constant for the initial query
* - SELECT options array for the initial query
- * - DB_MASTER constant for the fallback query; null if no fallback should happen
+ * - DB_PRIMARY constant for the fallback query; null if no fallback should happen
* - SELECT options array for the fallback query; empty if no fallback should happen
*/
public static function getDBOptions( $bitfield ) {
diff --git a/includes/dao/IDBAccessObject.php b/includes/dao/IDBAccessObject.php
index a88d4f9b3250..072cf2a5e74d 100644
--- a/includes/dao/IDBAccessObject.php
+++ b/includes/dao/IDBAccessObject.php
@@ -30,13 +30,13 @@
*
* There are four types of reads:
* - READ_NORMAL : Potentially cached read of data (e.g. from a replica DB or stale replica)
- * - READ_LATEST : Up-to-date read as of transaction start (e.g. from master or a quorum read)
+ * - READ_LATEST : Up-to-date read as of transaction start (e.g. from primary or a quorum read)
* - READ_LOCKING : Up-to-date read as of now, that locks (shared) the records
* - READ_EXCLUSIVE : Up-to-date read as of now, that locks (exclusive) the records
* All record locks persist for the duration of the transaction.
*
* A special constant READ_LATEST_IMMUTABLE can be used for fetching append-only data. Such
- * data is either (a) on a replica DB and up-to-date or (b) not yet there, but on the master/quorum.
+ * data is either (a) on a replica DB and up-to-date or (b) not yet there, but on the primary/quorum.
* Because the data is append-only, it can never be stale on a replica DB if present.
*
* Callers should use READ_NORMAL (or pass in no flags) unless the read determines a write.
@@ -59,16 +59,16 @@ interface IDBAccessObject {
/** @var int Read from a replica DB/non-quorum */
public const READ_NORMAL = 0;
- /** @var int Read from the master/quorum */
+ /** @var int Read from the primary/quorum */
public const READ_LATEST = 1;
- /** @var int Read from the master/quorum and lock out other writers */
+ /** @var int Read from the primary/quorum and lock out other writers */
public const READ_LOCKING = self::READ_LATEST | 2; // READ_LATEST (1) and "LOCK IN SHARE MODE" (2)
- /** @var int Read from the master/quorum and lock out other writers and locking readers */
+ /** @var int Read from the primary/quorum and lock out other writers and locking readers */
public const READ_EXCLUSIVE = self::READ_LOCKING | 4; // READ_LOCKING (3) and "FOR UPDATE" (4)
- /** @var int Read from a replica DB or without a quorum, using the master/quorum on miss */
+ /** @var int Read from a replica DB or without a quorum, using the primary/quorum on miss */
public const READ_LATEST_IMMUTABLE = 8;
// Convenience constant for tracking how data was loaded (higher => higher QoS)
diff --git a/includes/deferred/UserEditCountUpdate.php b/includes/deferred/UserEditCountUpdate.php
index d78d437015d2..400cb24521e2 100644
--- a/includes/deferred/UserEditCountUpdate.php
+++ b/includes/deferred/UserEditCountUpdate.php
@@ -87,7 +87,7 @@ class UserEditCountUpdate implements DeferrableUpdate, MergeableUpdate {
// Since this update runs after the new revisions were committed,
// wait for the replica DB to catch up so they will be counted.
$dbr = $lb->getConnectionRef( DB_REPLICA );
- // If $dbr is actually the master DB, then clearing the snapshot
+ // If $dbr is actually the primary DB, then clearing the snapshot
// is harmless and waitForMasterPos() will just no-op.
$dbr->flushSnapshot( $fname );
$lb->waitForMasterPos( $dbr );
diff --git a/includes/externalstore/ExternalStoreDB.php b/includes/externalstore/ExternalStoreDB.php
index 4f157f9a0ee8..7efa28411234 100644
--- a/includes/externalstore/ExternalStoreDB.php
+++ b/includes/externalstore/ExternalStoreDB.php
@@ -182,7 +182,7 @@ class ExternalStoreDB extends ExternalStoreMedium {
}
/**
- * Get a master database connection for the specified cluster
+ * Get a primary database connection for the specified cluster
*
* @param string $cluster Cluster name
* @return MaintainableDBConnRef
@@ -363,10 +363,10 @@ class ExternalStoreDB extends ExternalStoreMedium {
}
if ( $ids ) {
$this->logger->info(
- __METHOD__ . ": master fallback on '$cluster' for: " .
+ __METHOD__ . ": primary fallback on '$cluster' for: " .
implode( ',', array_keys( $ids ) )
);
- // Try the master
+ // Try the primary
$dbw = $this->getMaster( $cluster );
$res = $dbw->select(
$this->getTable( $dbr, $cluster ),
@@ -374,14 +374,14 @@ class ExternalStoreDB extends ExternalStoreMedium {
[ 'blob_id' => array_keys( $ids ) ],
__METHOD__ );
if ( $res === false ) {
- $this->logger->error( __METHOD__ . ": master failed on '$cluster'" );
+ $this->logger->error( __METHOD__ . ": primary failed on '$cluster'" );
} else {
$this->mergeBatchResult( $ret, $ids, $res );
}
}
if ( $ids ) {
$this->logger->error(
- __METHOD__ . ": master on '$cluster' failed locating items: " .
+ __METHOD__ . ": primary on '$cluster' failed locating items: " .
implode( ',', array_keys( $ids ) )
);
}
diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php
index 643c2d8aa688..b5cd4a710e7e 100644
--- a/includes/filerepo/LocalRepo.php
+++ b/includes/filerepo/LocalRepo.php
@@ -486,7 +486,7 @@ class LocalRepo extends FileRepo {
}
/**
- * Get a connection to the master DB
+ * Get a connection to the primary DB
* @return IDatabase
*/
public function getMasterDB() {
@@ -494,7 +494,7 @@ class LocalRepo extends FileRepo {
}
/**
- * Get a callback to get a DB handle given an index (DB_REPLICA/DB_MASTER)
+ * Get a callback to get a DB handle given an index (DB_REPLICA/DB_PRIMARY)
* @return Closure
*/
protected function getDBFactory() {
diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php
index 1552325611d2..1ccb00f832ef 100644
--- a/includes/jobqueue/JobQueueDB.php
+++ b/includes/jobqueue/JobQueueDB.php
@@ -794,7 +794,7 @@ class JobQueueDB extends JobQueue {
}
/**
- * @param int $index (DB_REPLICA/DB_MASTER)
+ * @param int $index (DB_REPLICA/DB_PRIMARY)
* @return IMaintainableDatabase
*/
protected function getDB( $index ) {
diff --git a/includes/jobqueue/jobs/RefreshLinksJob.php b/includes/jobqueue/jobs/RefreshLinksJob.php
index cbe0569edc3a..b95c268d09e1 100644
--- a/includes/jobqueue/jobs/RefreshLinksJob.php
+++ b/includes/jobqueue/jobs/RefreshLinksJob.php
@@ -91,7 +91,7 @@ class RefreshLinksJob extends Job {
// Job to update all (or a range of) backlink pages for a page
if ( !empty( $this->params['recursive'] ) ) {
$services = MediaWikiServices::getInstance();
- // When the base job branches, wait for the replica DBs to catch up to the master.
+ // When the base job branches, wait for the replica DBs to catch up to the primary.
// From then on, we know that any template changes at the time the base job was
// enqueued will be reflected in backlink page parses when the leaf jobs run.
if ( !isset( $this->params['range'] ) ) {
@@ -150,7 +150,7 @@ class RefreshLinksJob extends Job {
$lbFactory = $services->getDBLoadBalancerFactory();
$ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
- // Load the page from the master DB
+ // Load the page from the primary DB
$page = $services->getWikiPageFactory()->newFromTitle( $title );
$page->loadPageData( WikiPage::READ_LATEST );
diff --git a/includes/libs/rdbms/database/DBConnRef.php b/includes/libs/rdbms/database/DBConnRef.php
index 9e42934df55a..c11ff00aeb5e 100644
--- a/includes/libs/rdbms/database/DBConnRef.php
+++ b/includes/libs/rdbms/database/DBConnRef.php
@@ -33,7 +33,7 @@ class DBConnRef implements IDatabase {
private $conn;
/** @var array N-tuple of (server index, group, DatabaseDomain|string) */
private $params;
- /** @var int One of DB_MASTER/DB_REPLICA */
+ /** @var int One of DB_PRIMARY/DB_REPLICA */
private $role;
private const FLD_INDEX = 0;
@@ -44,7 +44,7 @@ class DBConnRef implements IDatabase {
/**
* @param ILoadBalancer $lb Connection manager for $conn
* @param IDatabase|array $conn Database or (server index, query groups, domain, flags)
- * @param int $role The type of connection asked for; one of DB_MASTER/DB_REPLICA
+ * @param int $role The type of connection asked for; one of DB_PRIMARY/DB_REPLICA
* @internal This method should not be called outside of LoadBalancer
*/
public function __construct( ILoadBalancer $lb, $conn, $role ) {
@@ -69,7 +69,7 @@ class DBConnRef implements IDatabase {
}
/**
- * @return int DB_MASTER when this *requires* the master DB, otherwise DB_REPLICA
+ * @return int DB_PRIMARY when this *requires* the master DB, otherwise DB_REPLICA
* @since 1.33
*/
public function getReferenceRole() {
@@ -772,7 +772,7 @@ class DBConnRef implements IDatabase {
}
/**
- * Error out if the role is not DB_MASTER
+ * 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).
@@ -780,12 +780,12 @@ class DBConnRef implements IDatabase {
* 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_MASTER/DB_REPLICA will sometimes (or always) use the same connection to the master DB.
+ * DB_PRIMARY/DB_REPLICA will sometimes (or always) use the same connection to the master DB.
* This does not effect the role of DBConnRef instances.
* @throws DBReadOnlyRoleError
*/
protected function assertRoleAllowsWrites() {
- // DB_MASTER is "prima facie" writable
+ // DB_PRIMARY is "prima facie" writable
if ( $this->role !== ILoadBalancer::DB_PRIMARY ) {
throw new DBReadOnlyRoleError( $this->conn, "Cannot write with role DB_REPLICA" );
}
diff --git a/includes/libs/rdbms/loadbalancer/ILoadBalancer.php b/includes/libs/rdbms/loadbalancer/ILoadBalancer.php
index e34743a33c25..3eff969f8745 100644
--- a/includes/libs/rdbms/loadbalancer/ILoadBalancer.php
+++ b/includes/libs/rdbms/loadbalancer/ILoadBalancer.php
@@ -29,12 +29,12 @@ use LogicException;
/**
* Database cluster connection, tracking, load balancing, and transaction manager interface
*
- * A "cluster" is considered to be one master database and zero or more replica databases.
- * Typically, the replica DBs replicate from the master asynchronously. The first node in the
- * "servers" configuration array is always considered the "master". However, this class can still
- * be used when all or some of the "replica" DBs are multi-master peers of the master or even
+ * A "cluster" is considered to be one primary database and zero or more replica databases.
+ * Typically, the replica DBs replicate from the primary asynchronously. The first node in the
+ * "servers" configuration array is always considered the "primary". However, this class can still
+ * be used when all or some of the "replica" DBs are multi-primary peers of the primary or even
* when all the DBs are non-replicating clones of each other holding read-only data. Thus, the
- * role of "master" is in some cases merely nominal.
+ * role of "primary" is in some cases merely nominal.
*
* By default, each DB server uses DBO_DEFAULT for its 'flags' setting, unless explicitly set
* otherwise in configuration. DBO_DEFAULT behavior depends on whether 'cliMode' is set:
@@ -45,7 +45,7 @@ use LogicException;
* application must have some point where it calls commitMasterChanges() near the end of
* the PHP request.
* Every iteration of beginMasterChanges()/commitMasterChanges() is called a "transaction round".
- * Rounds are useful on the master DB connections because they make single-DB (and by and large
+ * Rounds are useful on the primary DB connections because they make single-DB (and by and large
* multi-DB) updates in web requests all-or-nothing. Also, transactions on replica DBs are useful
* when REPEATABLE-READ or SERIALIZABLE isolation is used because all foriegn keys and constraints
* hold across separate queries in the DB transaction since the data appears within a consistent
@@ -56,7 +56,7 @@ use LogicException;
* weighted random selection, adjustments thereof by LoadMonitor, and the amount of replication
* lag on each DB server. Lag checks might cause problems in certain setups, so they should be
* tuned in the server configuration maps as follows:
- * - Master + N Replica(s): set 'max lag' to an appropriate threshold for avoiding any database
+ * - Primary + N Replica(s): set 'max lag' to an appropriate threshold for avoiding any database
* lagged by this much or more. If all DBs are this lagged, then the load balancer considers
* the cluster to be read-only.
* - Galera Cluster: Seconds_Behind_Master will be 0, so there probably is nothing to tune.
@@ -71,7 +71,7 @@ use LogicException;
* would probably just randomly bounce around).
*
* If using a SQL proxy service, it would probably be best to have two proxy hosts for the
- * load balancer to talk to. One would be the 'host' of the master server entry and another for
+ * load balancer to talk to. One would be the 'host' of the primary server entry and another for
* the (logical) replica server entry. The proxy could map the load balancer's "replica" DB to
* any number of physical replica DBs.
*
@@ -104,7 +104,7 @@ interface ILoadBalancer {
public const CONN_TRX_AUTOCOMMIT = 1;
/** Return null on connection failure instead of throwing an exception */
public const CONN_SILENCE_ERRORS = 2;
- /** Caller is requesting the master DB server for possibly writes */
+ /** Caller is requesting the primary DB server for possibly writes */
public const CONN_INTENT_WRITABLE = 4;
/** Bypass and update any server-side read-only mode state cache */
public const CONN_REFRESH_READ_ONLY = 8;
@@ -121,7 +121,7 @@ interface ILoadBalancer {
* - servers : List of server info structures
* - localDomain: A DatabaseDomain or domain ID string
* - loadMonitor : LoadMonitor::__construct() parameters with "class" field. [optional]
- * - readOnlyReason : Reason the master DB is read-only if so [optional]
+ * - readOnlyReason : Reason the primary DB is read-only if so [optional]
* - waitTimeout : Maximum time to wait for replicas for consistency [optional]
* - maxLag: Try to avoid DB replicas with lag above this many seconds [optional]
* - srvCache : BagOStuff object for server cache [optional]
@@ -150,12 +150,12 @@ interface ILoadBalancer {
* Get the logical name of the database cluster
*
* This is useful for identifying a cluster or replicated dataset, even when:
- * - The master server is sometimes swapped with another one
+ * - The primary server is sometimes swapped with another one
* - The cluster/dataset is replicated among multiple datacenters, with one "primary"
- * datacenter having the writable master server and the other datacenters having a
- * read-only replica in the "master" server slot
+ * datacenter having the writable primary server and the other datacenters having a
+ * read-only replica in the "primary" server slot
* - The dataset is replicated among multiple datacenters, via circular replication,
- * with each datacenter having its own "master" server
+ * with each datacenter having its own "primary" server
*
* @return string
* @since 1.36
@@ -215,7 +215,7 @@ interface ILoadBalancer {
public function getReaderIndex( $group = false, $domain = false );
/**
- * Set the master position to reach before the next generic group DB handle query
+ * Set the primary position to reach before the next generic group DB handle query
*
* If a generic replica DB connection is already open then this immediately waits
* for that DB to catch up to the specified replication position. Otherwise, it will
@@ -225,31 +225,31 @@ interface ILoadBalancer {
* will return true. This is useful for discouraging clients from taking further actions
* if session consistency could not be maintained with respect to their last actions.
*
- * @param DBMasterPos|bool $pos Master position or false
+ * @param DBMasterPos|bool $pos Primary position or false
*/
public function waitFor( $pos );
/**
- * Set the master wait position and wait for a generic replica DB to catch up to it
+ * Set the primary wait position and wait for a generic replica DB to catch up to it
*
* This method is only intented for use a throttling mechanism for high-volume updates.
* Unlike waitFor(), failure does not effect getLaggedReplicaMode()/laggedReplicaUsed().
*
* This can be used a faster proxy for waitForAll()
*
- * @param DBMasterPos|bool $pos Master position or false
+ * @param DBMasterPos|bool $pos Primary position or false
* @param int|null $timeout Max seconds to wait; default is mWaitTimeout
* @return bool Success (able to connect and no timeouts reached)
*/
public function waitForOne( $pos, $timeout = null );
/**
- * Set the master wait position and wait for ALL replica DBs to catch up to it
+ * Set the primary wait position and wait for ALL replica DBs to catch up to it
*
* This method is only intented for use a throttling mechanism for high-volume updates.
* Unlike waitFor(), failure does not effect getLaggedReplicaMode()/laggedReplicaUsed().
*
- * @param DBMasterPos|bool $pos Master position or false
+ * @param DBMasterPos|bool $pos Primary position or false
* @param int|null $timeout Max seconds to wait; default is mWaitTimeout
* @return bool Success (able to connect and no timeouts reached)
*/
@@ -264,25 +264,25 @@ interface ILoadBalancer {
* This method is largely intended for internal by RDBMs callers that issue queries that do
* not affect any current transaction.
*
- * @param int $i Specific or virtual (DB_MASTER/DB_REPLICA) server index
+ * @param int $i Specific or virtual (DB_PRIMARY/DB_REPLICA) server index
* @param int $flags Bitfield of CONN_* class constants
* @return Database|bool False if no such connection is open
*/
public function getAnyOpenConnection( $i, $flags = 0 );
/**
- * Get a live handle for a specific or virtual (DB_MASTER/DB_REPLICA) server index
+ * Get a live handle for a specific or virtual (DB_PRIMARY/DB_REPLICA) server index
*
* The server index, $i, can be one of the following:
* - DB_REPLICA: a server index will be selected by the load balancer based on read
- * weight, connectivity, and replication lag. Note that the master server might be
+ * weight, connectivity, and replication lag. Note that the primary server might be
* configured with read weight. If $groups is empty then it means "the generic group",
* in which case all servers defined with read weight will be considered. Additional
* query groups can be configured, having their own list of server indexes and read
* weights. If a query group list is provided in $groups, then each recognized group
* will be tried, left-to-right, until server index selection succeeds or all groups
* have been tried, in which case the generic group will be tried.
- * - DB_MASTER: the master server index will be used; the same as getWriterIndex().
+ * - DB_PRIMARY: the primary server index will be used; the same as getWriterIndex().
* The value of $groups should be [] when using this server index.
* - Specific server index: a positive integer can be provided to use the server with
* that index. An error will be thrown in no such server index is recognized. This
@@ -299,7 +299,7 @@ interface ILoadBalancer {
* will be made if there are none.
*
* Handle sharing is particularly useful when callers get local DB domain (the default),
- * transaction round aware (the default), DB_MASTER handles. All such callers will operate
+ * transaction round aware (the default), DB_PRIMARY handles. All such callers will operate
* within a single database transaction as a consequence. Handle sharing is also useful when
* callers get local DB domain (the default), transaction round aware (the default), samely
* query grouped (the default), DB_REPLICA handles. All such callers will operate within a
@@ -320,7 +320,7 @@ interface ILoadBalancer {
* @see ILoadBalancer::reuseConnection()
* @see ILoadBalancer::getServerAttributes()
*
- * @param int $i Specific (overrides $groups) or virtual (DB_MASTER/DB_REPLICA) server index
+ * @param int $i Specific (overrides $groups) or virtual (DB_PRIMARY/DB_REPLICA) server index
* @param string[]|string $groups Query group(s) in preference order; [] for the default group
* @param string|bool $domain DB domain ID or false for the local domain
* @param int $flags Bitfield of CONN_* class constants
@@ -338,7 +338,7 @@ interface ILoadBalancer {
* Get a live handle for a specific server index
*
* This is a simpler version of getConnection() that does not accept virtual server
- * indexes (e.g. DB_MASTER/DB_REPLICA), does not assure that master DB handles have
+ * indexes (e.g. DB_PRIMARY/DB_REPLICA), does not assure that primary DB handles have
* read-only mode when there is high replication lag, and can only trigger attempts
* to connect to a single server (the one with the specified server index).
*
@@ -376,7 +376,7 @@ interface ILoadBalancer {
*
* @see ILoadBalancer::getConnection() for parameter information
*
- * @param int $i Specific or virtual (DB_MASTER/DB_REPLICA) server index
+ * @param int $i Specific or virtual (DB_PRIMARY/DB_REPLICA) server index
* @param string[]|string $groups Query group(s) in preference order; [] for the default group
* @param string|bool $domain DB domain ID or false for the local domain
* @param int $flags Bitfield of CONN_* class constants (e.g. CONN_TRX_AUTOCOMMIT)
@@ -397,7 +397,7 @@ interface ILoadBalancer {
*
* @see ILoadBalancer::getConnection() for parameter information
*
- * @param int $i Specific or virtual (DB_MASTER/DB_REPLICA) server index
+ * @param int $i Specific or virtual (DB_PRIMARY/DB_REPLICA) server index
* @param string[]|string $groups Query group(s) in preference order; [] for the default group
* @param string|bool $domain DB domain ID or false for the local domain
* @param int $flags Bitfield of CONN_* class constants
@@ -420,7 +420,7 @@ interface ILoadBalancer {
*
* @see ILoadBalancer::getConnection() for parameter information
*
- * @param int $i Specific or virtual (DB_MASTER/DB_REPLICA) server index
+ * @param int $i Specific or virtual (DB_PRIMARY/DB_REPLICA) server index
* @param string[]|string $groups Query group(s) in preference order; [] for the default group
* @param string|bool $domain DB domain ID or false for the local domain
* @param int $flags Bitfield of CONN_* class constants (e.g. CONN_TRX_AUTOCOMMIT)
@@ -431,7 +431,7 @@ interface ILoadBalancer {
public function getMaintenanceConnectionRef( $i, $groups = [], $domain = false, $flags = 0 );
/**
- * Get the specific server index of the master server
+ * Get the specific server index of the primary server
*
* @return int
*/
@@ -447,8 +447,8 @@ interface ILoadBalancer {
/**
* Whether there are any replica servers configured
*
- * This counts both servers using streaming replication from the master server and
- * servers that just have a clone of the static dataset found on the master server
+ * This counts both servers using streaming replication from the primary server and
+ * servers that just have a clone of the static dataset found on the primary server
*
* @return int
* @since 1.34
@@ -456,7 +456,7 @@ interface ILoadBalancer {
public function hasReplicaServers();
/**
- * Whether any replica servers use streaming replication from the master server
+ * Whether any replica servers use streaming replication from the primary server
*
* Generally this is one less than getServerCount(), though it might otherwise
* return a lower number if some of the servers are configured with "is static".
@@ -512,7 +512,7 @@ interface ILoadBalancer {
public function getServerAttributes( $i );
/**
- * Get the current master replication position
+ * Get the current primary replication position
*
* @return DBMasterPos|bool Returns false if not applicable
* @throws DBError
@@ -522,7 +522,7 @@ interface ILoadBalancer {
/**
* Get the highest DB replication position for chronology control purposes
*
- * If there is only a master server then this returns false. If replication is present
+ * If there is only a primary server then this returns false. If replication is present
* and correctly configured, then this returns the highest replication position of any
* server with an open connection. That position can later be passed to waitFor() on a
* new load balancer instance to make sure that queries on the new connections see data
@@ -597,7 +597,7 @@ interface ILoadBalancer {
public function approveMasterChanges( array $options, $fname = __METHOD__, $owner = null );
/**
- * Flush any master transaction snapshots and set DBO_TRX (if DBO_DEFAULT is set)
+ * Flush any primary transaction snapshots and set DBO_TRX (if DBO_DEFAULT is set)
*
* The DBO_TRX setting will be reverted to the default in each of these methods:
* - commitMasterChanges()
@@ -612,7 +612,7 @@ interface ILoadBalancer {
public function beginMasterChanges( $fname = __METHOD__, $owner = null );
/**
- * Issue COMMIT on all open master connections to flush changes and view snapshots
+ * Issue COMMIT on all open primary connections to flush changes and view snapshots
* @param string $fname Caller name
* @param int|null $owner ID of the calling instance (e.g. the LBFactory ID)
* @throws DBExpectedError
@@ -638,7 +638,7 @@ interface ILoadBalancer {
public function runMasterTransactionListenerCallbacks( $fname = __METHOD__, $owner = null );
/**
- * Issue ROLLBACK only on master, only if queries were done on connection
+ * Issue ROLLBACK only on primary, only if queries were done on connection
* @param string $fname Caller name
* @param int|null $owner ID of the calling instance (e.g. the LBFactory ID)
* @throws DBExpectedError
@@ -654,7 +654,7 @@ interface ILoadBalancer {
public function flushReplicaSnapshots( $fname = __METHOD__, $owner = null );
/**
- * Commit all master DB transactions so as to flush any REPEATABLE-READ or SSI snapshots
+ * Commit all primary DB transactions so as to flush any REPEATABLE-READ or SSI snapshots
*
* An error will be thrown if a connection has pending writes or callbacks
*
@@ -664,7 +664,7 @@ interface ILoadBalancer {
public function flushMasterSnapshots( $fname = __METHOD__, $owner = null );
/**
- * @return bool Whether a master connection is already open
+ * @return bool Whether a primary connection is already open
*/
public function hasMasterConnection();
@@ -690,7 +690,7 @@ interface ILoadBalancer {
public function hasOrMadeRecentMasterChanges( $age = null );
/**
- * Get the list of callers that have pending master changes
+ * Get the list of callers that have pending primary changes
*
* @return string[] List of method names
*/
@@ -716,7 +716,7 @@ interface ILoadBalancer {
/**
* @note This method may trigger a DB connection if not yet done
* @param string|bool $domain DB domain ID or false for the local domain
- * @return string|bool Reason the master is read-only or false if it is not
+ * @return string|bool Reason the primary is read-only or false if it is not
*/
public function getReadOnlyReason( $domain = false );
@@ -740,7 +740,7 @@ interface ILoadBalancer {
public function forEachOpenConnection( $callback, array $params = [] );
/**
- * Call a function with each open connection object to a master
+ * Call a function with each open connection object to a primary
* @param callable $callback
* @param array $params
*/
@@ -778,14 +778,14 @@ interface ILoadBalancer {
public function getLagTimes( $domain = false );
/**
- * Wait for a replica DB to reach a specified master position
+ * Wait for a replica DB to reach a specified primary position
*
* If $conn is not a replica server connection, then this will return true.
- * Otherwise, if $pos is not provided, this will connect to the master server
+ * Otherwise, if $pos is not provided, this will connect to the primary server
* to get an accurate position.
*
* @param IDatabase $conn Replica DB
- * @param DBMasterPos|bool $pos Master position; default: current position
+ * @param DBMasterPos|bool $pos Primary position; default: current position
* @param int $timeout Timeout in seconds [optional]
* @return bool Success
* @since 1.34
@@ -794,7 +794,7 @@ interface ILoadBalancer {
/**
* Set a callback via IDatabase::setTransactionListener() on
- * all current and future master connections of this load balancer
+ * all current and future primary connections of this load balancer
*
* @param string $name Callback name
* @param callable|null $callback
diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php
index c31f4725cf4c..ee9a067a67f2 100644
--- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php
+++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php
@@ -329,7 +329,7 @@ class LoadBalancer implements ILoadBalancer {
* Resolve $groups into a list of query groups defining as having database servers
*
* @param string[]|string|bool $groups Query group(s) in preference order, [], or false
- * @param int $i Specific server index or DB_MASTER/DB_REPLICA
+ * @param int $i Specific server index or DB_PRIMARY/DB_REPLICA
* @return string[] Non-empty group list in preference order with the default group appended
*/
private function resolveGroups( $groups, $i ) {
@@ -357,7 +357,7 @@ class LoadBalancer implements ILoadBalancer {
/**
* @param int $flags Bitfield of class CONN_* constants
- * @param int $i Specific server index or DB_MASTER/DB_REPLICA
+ * @param int $i Specific server index or DB_PRIMARY/DB_REPLICA
* @param string $domain Database domain
* @return int Sanitized bitfield
*/
@@ -497,7 +497,7 @@ class LoadBalancer implements ILoadBalancer {
/**
* Get the server index to use for a specified server index and query group list
*
- * @param int $i Specific server index or DB_MASTER/DB_REPLICA
+ * @param int $i Specific server index or DB_PRIMARY/DB_REPLICA
* @param string[] $groups Non-empty query group list in preference order
* @param string|bool $domain
* @return int A specific server index (replica DBs are checked for connectivity)
@@ -955,7 +955,7 @@ class LoadBalancer implements ILoadBalancer {
$domain = $this->resolveDomainID( $domain );
$groups = $this->resolveGroups( $groups, $i );
$flags = $this->sanitizeConnectionFlags( $flags, $i, $domain );
- // If given DB_MASTER/DB_REPLICA, resolve it to a specific server index. Resolving
+ // If given DB_PRIMARY/DB_REPLICA, resolve it to a specific server index. Resolving
// DB_REPLICA might trigger getServerConnection() calls due to the getReaderIndex()
// connectivity checks or LoadMonitor::scaleLoads() server state cache regeneration.
// The use of getServerConnection() instead of getConnection() avoids infinite loops.
@@ -1133,8 +1133,8 @@ class LoadBalancer implements ILoadBalancer {
}
/**
- * @param int $i Server index or DB_MASTER/DB_REPLICA
- * @return int One of DB_MASTER/DB_REPLICA
+ * @param int $i Server index or DB_PRIMARY/DB_REPLICA
+ * @return int One of DB_PRIMARY/DB_REPLICA
*/
private function getRoleFromIndex( $i ) {
return ( $i === self::DB_PRIMARY || $i === $this->getWriterIndex() )
diff --git a/includes/page/PageStore.php b/includes/page/PageStore.php
index 72c4dfd765fa..f2718e9a5695 100644
--- a/includes/page/PageStore.php
+++ b/includes/page/PageStore.php
@@ -300,7 +300,7 @@ class PageStore implements PageLookup {
}
/**
- * @param int $mode DB_MASTER or DB_REPLICA
+ * @param int $mode DB_PRIMARY or DB_REPLICA
* @return IDatabase
*/
private function getDBConnectionRef( int $mode = DB_REPLICA ): IDatabase {
diff --git a/includes/user/BotPassword.php b/includes/user/BotPassword.php
index b29df06b90e6..7adfa99054b6 100644
--- a/includes/user/BotPassword.php
+++ b/includes/user/BotPassword.php
@@ -89,7 +89,7 @@ class BotPassword implements IDBAccessObject {
/**
* Get a database connection for the bot passwords database
- * @param int $db Index of the connection to get, e.g. DB_MASTER or DB_REPLICA.
+ * @param int $db Index of the connection to get, e.g. DB_PRIMARY or DB_REPLICA.
* @return IDatabase
*/
public static function getDB( $db ) {
diff --git a/includes/watcheditem/WatchedItemStore.php b/includes/watcheditem/WatchedItemStore.php
index 80464b3cabc9..64fe920d758b 100644
--- a/includes/watcheditem/WatchedItemStore.php
+++ b/includes/watcheditem/WatchedItemStore.php
@@ -293,7 +293,7 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
}
/**
- * @param int $dbIndex DB_MASTER or DB_REPLICA
+ * @param int $dbIndex DB_PRIMARY or DB_REPLICA
*
* @return IDatabase
*/
diff --git a/maintenance/includes/Maintenance.php b/maintenance/includes/Maintenance.php
index b75c881d730d..8f9482336b62 100644
--- a/maintenance/includes/Maintenance.php
+++ b/maintenance/includes/Maintenance.php
@@ -1341,7 +1341,7 @@ abstract class Maintenance {
*
* @stable for overriding
*
- * @param int $db DB index (DB_REPLICA/DB_MASTER)
+ * @param int $db DB index (DB_REPLICA/DB_PRIMARY)
* @param string|string[] $groups default: empty array
* @param string|bool $dbDomain default: current wiki
* @return IMaintainableDatabase