UpdateRepo uses LoadBalancer only in a single place, but hasn't been done with DomainDb until now:
/** * Get the time (in seconds) for which the job execution should be delayed * (if delayed jobs are enabled). Defaults to the max replag of any pooled * DB server + 2 seconds. * * @return int */ protected function getJobDelay() { $lagArray = MediaWikiServices::getInstance()->getDBLoadBalancer()->getMaxLag(); // This should be good enough, especially given that lagged servers get // less load by the load balancer, thus it's very unlikely we'll end // up on the server with the highest lag. // We add +2 here, to make sure we have a minimum delay of a full // second (this is being added to time() so +1 actually just means // wait until this second is over). return $lagArray[1] + 2; }
This getMaxLag should be somehow added to the DomainDb and then used in UpdateRepo
Incomplete list of Things to Consider when working on this:
- Should getMaxLag be added to the ReplicationWaiter or its own little service/interface?
- Should we return the complete lag array ({0:string,1:float|int|false,2:int} (host, max lag, index of max lagged host)) or just one piece of info or maybe same info in a different structure / value object?
- Do we maybe want to implement more of the lag-related methods in the future? (We want to avoid having an interface specifying 61 methods, but also some methods maybe "belong" together.)