Description
Related Objects
Event Timeline
Suggestion given by @Ladsgroup
https://phabricator.wikimedia.org/T399083#11039284
slow it down with --sleep and add 1s between in each batch, put it in mwscript-k8s and let it run it for a day or a week.
https://phabricator.wikimedia.org/T399083#11039355
make sure you don't hit --follow and if you do, put it on a screen
More details about running maintenance scripts: https://wikitech.wikimedia.org/wiki/Maintenance_scripts
I've started running the script:
mwscript-k8s --comment="Run compress-corpora-content.php with 1s sleep (T399084)" -- extensions/ContentTranslation/scripts/compress-corpora-content.php --wiki=enwiki --sleep=1 --really ⏳ Starting extensions/ContentTranslation/scripts/compress-corpora-content.php on Kubernetes as job mw-script.eqiad.32o8x99h ... 👋 Refreshing the local Helm cache... 🚀 Job is running. For streaming logs, run: K8S_CLUSTER=eqiad KUBECONFIG=/etc/kubernetes/mw-script-restricted-eqiad.config kubectl logs -f job/mw-script.eqiad.32o8x99h mediawiki-32o8x99h-app
Progress report:
Batch completed. Processed: 5,816,700, Compressed: 4,493,896 records so far Last processed ID: 7102190
Total records: 83,657,300
Awesome! I think it's fine to take long. It's better than causing major issues to the database. I'd assume it'd take around 20 days? That's fine from my side.
Progress report:
Batch completed. Processed: 12,759,200, Compressed: 9785652 records so far Last processed ID: 15540811
Should take <15 days as per my calculations.
Update:
Batch completed. Processed: 18,219,200, Compressed: 13558940 records so far Last processed ID: 22375440
Total records: 83,657,300
Update:
Batch completed. Processed: 32,388,000, Compressed: 24571731 records so far Last processed ID: 40527216
Noting that we got an alert for size of x1 in total increasing by 20% in just one week. The biggest increase in size is actually this table:
Maybe we are not deleting the old rows? or it's an in-place update?
Update:
Batch completed. Processed: 56,871,400, Compressed: 43,345,672 records so far Last processed ID: 71,968,298
Total records: 83,874,264
It's an in-place update. The number of rows haven't increased a lot so the size increase doesn't make sense.
I think I know why it exploded, mariadb is double compressing it on storage[1]. I will fix it while optimizing it. It should reduce the size.
[1] You might ask if mariadb is compressing it, why are we compressing it on the application layer: 1- It is not compressed on memory (where we are the most limited) 2- It is not compressed over network 3- It has a lot of limitations (https://mariadb.com/docs/server/server-usage/storage-engines/innodb/innodb-row-formats/innodb-compressed-row-format)
cumin2024@db2186.codfw.wmnet[wikishared]> show create table cx_corpora
-> ;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------>
| Table | Create Table >
+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------>
| cx_corpora | CREATE TABLE `cx_corpora` (
`cxc_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`cxc_translation_id` int(11) NOT NULL,
`cxc_section_id` varbinary(30) NOT NULL,
`cxc_origin` varbinary(30) NOT NULL,
`cxc_sequence_id` int(11) DEFAULT NULL,
`cxc_timestamp` binary(14) DEFAULT NULL,
`cxc_content` mediumblob DEFAULT NULL,
PRIMARY KEY (`cxc_id`),
UNIQUE KEY `cx_corpora_unique` (`cxc_translation_id`,`cxc_origin`,`cxc_section_id`,`cxc_timestamp`)
) ENGINE=InnoDB AUTO_INCREMENT=103260610 DEFAULT CHARSET=binary ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8 |
+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------>
1 row in set (0.031 sec)The script is complete.
[101043783] Compressed: 12026 -> 2431 bytes (79.79% reduction) [101043785] Skipped: compression does not reduce size Batch completed. Processed: 80881969, Compressed: 60014055 records so far Last processed ID: 101043785 Completed processing. Processed: 80881969, Compressed: 60014055 records (240.56 GB saved)
So far, result of T403362
50GB removed
root@db1179:/srv/sqldata/wikishared# ls -Ssh | head total 152G 131G cx_corpora.ibd 12G reading_list_entry.ibd
decent amount of storage saved and this considering that it was already compressed on disk.