The ImportConstraintStatements.php maintenance script in WikibaseQualityConstraints currently imports constraint statements for all properties in a simple loop, with no offset, limit, batching, or sleeping. This can potentially lead to a high DB load, and high replication lag.
Example:
We could group the imports into batches (with some default batch size, e. g. 100) and sleep between each batch (default e. g. 3 s). Batch size and sleep time should be configurable via command line arguments.
Some offset/limit arguments could also be added, so that a deployer can first import constraint statements for the first 1000 properties, then proceed later with the next 1000, and so on.
Acceptance criteria:
- The batch size of the maintenance script is configurable
- The script includes a wait for replication between batches
Original Comment:
As a deployer, I want to run the extensions/WikibaseQualityConstraints/maintenance/ImportConstraintStatements.php maintenance script when necessary in order to resolve problems with the constraint definitions, without having to worry about its impact on the wiki.
This only takes a few minutes – less than 10 ms for most properties, not much more for some larger properties, and we’re still well below 10000 properties – but it was enough to cause a visible traffic spike on the s8 master db host during the deployment for T223372 (around 13:17 UTC). As Wikidata keeps getting more properties, I believe this will gradually become more important.