It would be really nice to make MW be able to copy a whole wiki from one cluster to another. We already do similar work on table level (during table normalizations such as T300222: Implement normalizing MediaWiki link tables) and planning to even expand on duplicating full tables (T408137: Build a write duplicator system in mediawiki core) and expanding it to all of tables of a Wiki is not that much different.
Use cases:
- Merging two sections by moving all wikis (one by one) from one section to another which can save a lot of resources in terms of money, power consumption, CO2, Hardware, engineering time, etc.
- For example: T408834: Merging s6 wikis into s5
- Moving closed wikis to a dedicated archive cluster with much smaller capacity to free up s3 and provide significant redaction in terms of number of files opened by the mariadb daemon.
- Making the infra much more elastic. If a wiki becomes a noisy neighbor, easily move that to another section. We move replicas from one section to another using a cookbook and some puppet changes, I dream of a day we can move a wiki from one section to another with that ease.
- (Maybe) Renaming a database. To ease T172035: Blockers for Wikimedia wiki domain renaming
Technical proposal:
- This can't be done on MariaDB level. It should be done on MediaWiki level. We should be able to mediawiki to duplicate every write it sees for wiki X from one master to another.
- It should be also automatically notice differences and heal the secondary cluster from the primary. So for example, if a row is being updated in the primary cluster that doesn't exist in secondary cluster, it should be able to read the data from primary, insert the row and then update it.
- Making auto_increment inserts work will be quite fun.
- There should be a mw maint script to go through all tables and duplicate the data.
Notes:
- Moving a small wiki can be easily done with this idea, it shouldn't even take more than half an hour to move a small wiki from one cluster to another.
- Moving should be done one wiki at a time. Otherwise, the extra amount of writes will be too much for the target cluster.
- For very large wikis, very likely we won't be able to add the extra updates while copying terabytes of data so it doesn't make sense to look it this proposal thinking of moving enwiki or wikidatawiki. Similarly if a wiki grows so big that would require a dedicated cluster, it'd be much simpler and safer to do the usual cluster split we have done many times.
- We definitely should start with very small wikis first and then move forward with larger wikis.
Open question:
- Maybe there is an off the shelf library in MySQL/MariaDB ecosystem that can do it (similar to pt-online-schema-change)?