diff options
author | Aaron Schulz <aschulz@wikimedia.org> | 2021-05-04 15:03:26 -0700 |
---|---|---|
committer | Aaron Schulz <aschulz@wikimedia.org> | 2021-05-05 14:38:19 -0700 |
commit | 9ba3f4a2f531eddae7bc60933c6b1562a18dea01 (patch) | |
tree | 841b60e1a8d9b91b3774f82d37e523492305b7c7 /includes | |
parent | 50ed27feacc032ad23c3cc866116d4b49923e7e2 (diff) | |
download | mediawikicore-9ba3f4a2f531eddae7bc60933c6b1562a18dea01.tar.gz mediawikicore-9ba3f4a2f531eddae7bc60933c6b1562a18dea01.zip |
rdbms: add an IDatabase method to expose DB server IDs
Bug: T274174
Change-Id: Ia81e64fa99154f43d27bfe070df03686eb4469c5
Diffstat (limited to 'includes')
-rw-r--r-- | includes/libs/rdbms/database/DBConnRef.php | 4 | ||||
-rw-r--r-- | includes/libs/rdbms/database/Database.php | 4 | ||||
-rw-r--r-- | includes/libs/rdbms/database/DatabaseMysqlBase.php | 12 | ||||
-rw-r--r-- | includes/libs/rdbms/database/DatabaseSqlite.php | 5 | ||||
-rw-r--r-- | includes/libs/rdbms/database/IDatabase.php | 27 |
5 files changed, 47 insertions, 5 deletions
diff --git a/includes/libs/rdbms/database/DBConnRef.php b/includes/libs/rdbms/database/DBConnRef.php index 335aed8a6037..9e42934df55a 100644 --- a/includes/libs/rdbms/database/DBConnRef.php +++ b/includes/libs/rdbms/database/DBConnRef.php @@ -80,6 +80,10 @@ class DBConnRef implements IDatabase { return $this->__call( __FUNCTION__, func_get_args() ); } + public function getTopologyBasedServerId() { + return $this->__call( __FUNCTION__, func_get_args() ); + } + public function getTopologyRole() { return $this->__call( __FUNCTION__, func_get_args() ); } diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index 6992115535d9..31ec74d527d1 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -578,6 +578,10 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware return $this->getServerVersion(); } + public function getTopologyBasedServerId() { + return null; + } + public function getTopologyRole() { return $this->topologyRole; } diff --git a/includes/libs/rdbms/database/DatabaseMysqlBase.php b/includes/libs/rdbms/database/DatabaseMysqlBase.php index 39ec9b4cbc00..0b613bfaf53a 100644 --- a/includes/libs/rdbms/database/DatabaseMysqlBase.php +++ b/includes/libs/rdbms/database/DatabaseMysqlBase.php @@ -1022,9 +1022,14 @@ abstract class DatabaseMysqlBase extends Database { return $pos; } + public function getTopologyBasedServerId() { + // The server_id variable is unique to the replication topology for the dataset + return $this->getServerId(); + } + /** - * @return int - * @throws DBQueryError If the variable doesn't exist for some reason + * @return int Server ID that is unique to the replication topology and is not reused + * @throws DBQueryError */ protected function getServerId() { $fname = __METHOD__; @@ -1041,7 +1046,8 @@ abstract class DatabaseMysqlBase extends Database { } /** - * @return string|null + * @return string|null Server ID that should be globally unique + * @throws DBQueryError */ protected function getServerUUID() { $fname = __METHOD__; diff --git a/includes/libs/rdbms/database/DatabaseSqlite.php b/includes/libs/rdbms/database/DatabaseSqlite.php index 25ef4b74a31a..d514e6171573 100644 --- a/includes/libs/rdbms/database/DatabaseSqlite.php +++ b/includes/libs/rdbms/database/DatabaseSqlite.php @@ -739,6 +739,11 @@ class DatabaseSqlite extends Database { return false; } + public function getTopologyBasedServerId() { + // Sqlite topologies trivially consist of single master server for the dataset + return 0; + } + public function serverIsReadOnly() { $this->assertHasConnectionHandle(); diff --git a/includes/libs/rdbms/database/IDatabase.php b/includes/libs/rdbms/database/IDatabase.php index dbcaf9c9caad..1be134451718 100644 --- a/includes/libs/rdbms/database/IDatabase.php +++ b/includes/libs/rdbms/database/IDatabase.php @@ -164,17 +164,40 @@ interface IDatabase { public function getServerInfo(); /** + * Get a non-recycled ID that uniquely identifies this server within the replication topology + * + * A replication topology defines which servers can originate changes to a given dataset + * and how those changes propagate among database servers. It is assumed that the server + * only participates in the replication of a single relevant dataset. + * + * @return int|null Unique integer ID; null if not applicable or unknown + * @throws DBQueryError + * @since 1.37 + */ + public function getTopologyBasedServerId(); + + /** * Get the replication topology role of this server * + * A replication topology defines which servers can originate changes to a given dataset + * and how those changes propagate among database servers. It is assumed that the server + * only participates in the replication of a single relevant dataset. + * * @return string One of the class ROLE_* constants + * @throws DBQueryError * @since 1.34 */ public function getTopologyRole(); /** - * Get the host (or address) of the root master server for the replication topology + * Get the readable name of the sole root master server for the replication topology + * + * A replication topology defines which servers can originate changes to a given dataset + * and how those changes propagate among database servers. It is assumed that the server + * only participates in the replication of a single relevant dataset. * - * @return string|null Master server name or null if not known + * @return string|null Readable server name; null if unknown or if co-masters are defined + * @throws DBQueryError * @since 1.34 */ public function getTopologyRootMaster(); |