Page MenuHomePhabricator

Add $wgExternalStoreConf to support mapping logical clusters to physical clusters
Open, LowPublic

Description

In wmf-config, we use logical cluster names in $wgDefaultExternalStore and define LBFactory clusters for each logical cluster. Many of these logical clusters reside on the same physical cluster. Cluster e1 has 15 logical clusters, for example. As of now, there are 23 logical clusters and 7 physical clusters. To make it easier to merge clusters as hardware gets better, the table names have a logical cluster suffix, so merging cluster X and Y into Z just means copying over blobs_X and blobs_Y tables onto cluster Z.

Currently, for each logical cluster, we stuff the cluster-suffixed table name in the LBFactory server info for all servers in that logical cluster. This does not belong there. Also, LBFactoryMulti has no idea that clusters are using the same servers/topology, so it might, for example, open 15 connections to es1 since it sees 15 different clusters. The only difference between these clusters is 'blobs table'.

It seems like there should be a wgExternalStoreConf setting that could hold the ExternalStore (location => physical cluster) mapping and unqualified blob table name. If not configured, then the 'blobs table' LBInfo would still be checked for compatibility. If configured, then then LBFactoryConf could just use the actual clusters from dbctl (e.g. rc1, es1-es7).

This would simplify etcd.php and make it easier to configure things like "lagDetectionOptions" in db-production.php or check "is static" in etcd.php to decide whether to have the WRITER_INDEX point to a remote DB server (T374534). Currently, there is the annoying hard-coded alias/cluster correspondence table. It would also reduce connection counts to es* servers.

So, we could have something like:

$wgExternalStoreConf = [
	'DB' => [
		// Map of logical storage "locations" to physical server clusters
		'clusterByLocation' => [
			'rc1' => 'es1',
			'cluster1' => 'es1',
			'cluster2' => 'es1',
			'cluster3' => 'es1',
			'cluster4' => 'es1',
			'cluster5' => 'es1',
			'cluster6' => 'es1',
			'cluster7' => 'es1',
			'cluster8' => 'es1',
			'cluster9' => 'es1',
			'cluster10' => 'es1',
			'cluster20' => 'es1',
			'cluster21' => 'es1',
			'cluster22' => 'es1',
			'cluster23' => 'es1',
			'cluster24' => 'es2',
			'cluster25' => 'es3',
			'cluster26' => 'es4',
			'cluster27' => 'es5',
			'cluster28' => 'es4',
			'cluster29' => 'es5',
			'cluster30' => 'es6',
			'cluster31' => 'es7'
		],
		// Suffix table names to simplify physical colocation of logical storage "locations"
		'blobsTableByLocation' => [
			'rc1' => 'blobs',
			'cluster1' => 'blobs_cluster1',
			'cluster2' => 'blobs_cluster2',
			'cluster3' => 'blobs_cluster3',
			'cluster4' => 'blobs_cluster4',
			'cluster5' => 'blobs_cluster5',
			'cluster6' => 'blobs_cluster6',
			'cluster7' => 'blobs_cluster7',
			'cluster8' => 'blobs_cluster8',
			'cluster9' => 'blobs_cluster9',
			'cluster10' => 'blobs_cluster10',
			'cluster20' => 'blobs_cluster20',
			'cluster21' => 'blobs_cluster21',
			'cluster22' => 'blobs_cluster22',
			'cluster23' => 'blobs_cluster23',
			'cluster24' => 'blobs_cluster24',
			'cluster25' => 'blobs_cluster25',
			'cluster26' => 'blobs_cluster26',
			'cluster27' => 'blobs_cluster27',
			'cluster28' => 'blobs_cluster28',
			'cluster29' => 'blobs_cluster29',
			'cluster30' => 'blobs_cluster30',
			'cluster31' => 'blobs_cluster31'
		]
	]
];