Most of the daily toil on our DBA team is caused by repetitive actions to change the state of individual databases or of entire sections. This right now is done via code deploys; a typical maintenance window on a single server can require at least 3 code deployments. This is not acceptable, and we decided to move the storage of such state from the code repository to our consistent datastore, etcd.
Given how critical and complex those data are, our standard confctl tool won't be enough to ensure data are correctly stored and to minimize the risk of errors and the strain on DBAs from using the tool.
This CLI tool, that I propose to call dbctl, will still be part of conftool, and will have the following functionalities:
- Depool/warmup/repool fully a database server
- Change weights per server
- Set which server is the master for each section
- Set read-only per-section or globally
I also have a basic proposal for a UI, and the corresponding safety checks.
Get the current configuration
- dbctl instance NAME get gets you all the current configuration of a mysql instance (so either host:port or host only if it's the default port)
- dbctl section [SECTION|all] get shows what is configured for that specific section, or for all of them as a well formatted yaml
- dbctl config get will get all the configuration, in the form of a data structure that will be read by MediaWiki
Depool one instance
First depool the resources we want on the instance
- dbctl instance [NAME] depool [--section SECTION] [--group GROUP] , where both section and groups are optional. If none is specified, it's assumed we will act on all of them
Then we commit the changes to the MediaWiki config
- dbctl config commit (means the instance is removed from sectionLoads and groupLoadsBySection in mediawiki-config)
Before we perform any write actions, we perform two basic sanity checks:
- we're not removing the master
- we're not leaving a section with less than N slaves (configurable)
further sanity checks might be added in the future.
Pool/warmup one instance
First pool the resources we want on the instance. If we add a `percentage
- dbctl instance [NAME] pool [--section SECTION] [--group GROUP] [--percentage 100], where both section and groups are optional. If none is specified, it's assumed we will act on all of them. Percentage indicates what percentage of the original weight should be used when repooling. This allows to perform warmups by increasing the percentage parameter from 0 to 100 in steps.
Then we commit the changes to the MediaWiki config
- dbctl config commit (means the instance is added back to sectionLoads and groupLoadsBySection in mediawiki-config, with the previously-stored weights * percentage * 0.01)
- Change the weights
- dbctl instance NAME set-weight [--section SECTION] [--group GROUP] WEIGHT
Then commit the configuration as shown before.
Set master for a section
- dbctl section SECTION set-master NAME sets the master for that specific section to NAME
- Will verify that the server is pooled for that section
- Should verify that the new master is not a sanitarium master [NOT IMPLEMENTED]
Then commit the configuration as shown before.
Set a section read-only/read-write
- dbctl section SECTION [ro|rw] REASON will set the section to readonly with the specified reason
Then commit the configuration as shown before.
Bootstrapping a new instance/section
As usual for conftool entities, the entities are created from yaml files, but once created they're uninitialized and won't appear in the configuration for mediawiki.
In order to initialize them, you need to edit the new object:
dbconfig [instance|section] NAME edit