This task looks at tackling 2 issues currently found in Wikibase, mainly exposed on Wikidata.
# It is easy to incorrectly wire connections and loadbalancers when different db clusters are used. See T281457
# We wan't a way to easily give all db connections from client or repo a "group" indicating where they come from (client / repo) See T262924#6498193
An abstraction should allow us to solve these 2 problems in a single place.
It would also be a first step in creating an abstraction between MediaWiki and Wikibase (though interfaces presented through such an abstraction would still be used (from the RDBMS lib package in core))
**1)**
Wikibase often needs to connect to multiple databases at once, most commonly the repository database and a client database.
These databases have different domains (dbnames) but can also live on different clusters, resulting in different LoadBalancer objects being needed.
During changes on at least 2 occurrences in the past 12 months code has been merged with issues using the correct LoadBalancer objects.
This most recently happened with {T281457}.
TBA find the other ticket
An abstraction could also abstract away some of the more complex db patterns that currently exist in our code, for example waiting for replication in the correct way.
See https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/602823 for an intial draft
**2)**
In order for DBAs to be able to segment database traffic more effectively, we want to provide additional information when we "request" connections.
This would, for example, allow DBAs to allocate seperate hardware dedicated to keeping "client" functionality online, even if database servers dedicated to "repo" functionality are overloaded for some reason.