X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Fjobqueue%2FJobQueueDB.php;h=0a8ae7fd51f5b076c8333cbaf866d4f4c1d90412;hb=6ce0b82f713f8731c04b28d27ac2637d6749dc70;hp=856cdfd61e99205962b71856fb0685e1a5d229b6;hpb=f0d760a0773eaaf840b8e5a1649b5c6a0f705f9d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php index 856cdfd61e..0a8ae7fd51 100644 --- a/includes/jobqueue/JobQueueDB.php +++ b/includes/jobqueue/JobQueueDB.php @@ -21,6 +21,7 @@ * @author Aaron Schulz */ use MediaWiki\MediaWikiServices; +use Wikimedia\ScopedCallback; /** * Class to handle job queues stored in the DB @@ -68,7 +69,7 @@ class JobQueueDB extends JobQueue { * @return bool */ protected function doIsEmpty() { - $dbr = $this->getSlaveDB(); + $dbr = $this->getReplicaDB(); try { $found = $dbr->selectField( // unclaimed job 'job', '1', [ 'job_cmd' => $this->type, 'job_token' => '' ], __METHOD__ @@ -93,7 +94,7 @@ class JobQueueDB extends JobQueue { } try { - $dbr = $this->getSlaveDB(); + $dbr = $this->getReplicaDB(); $size = (int)$dbr->selectField( 'job', 'COUNT(*)', [ 'job_cmd' => $this->type, 'job_token' => '' ], __METHOD__ @@ -122,7 +123,7 @@ class JobQueueDB extends JobQueue { return $count; } - $dbr = $this->getSlaveDB(); + $dbr = $this->getReplicaDB(); try { $count = (int)$dbr->selectField( 'job', 'COUNT(*)', [ 'job_cmd' => $this->type, "job_token != {$dbr->addQuotes( '' )}" ], @@ -153,7 +154,7 @@ class JobQueueDB extends JobQueue { return $count; } - $dbr = $this->getSlaveDB(); + $dbr = $this->getReplicaDB(); try { $count = (int)$dbr->selectField( 'job', 'COUNT(*)', [ @@ -323,7 +324,7 @@ class JobQueueDB extends JobQueue { $invertedDirection = false; // whether one job_random direction was already scanned // This uses a replication safe method for acquiring jobs. One could use UPDATE+LIMIT // instead, but that either uses ORDER BY (in which case it deadlocks in MySQL) or is - // not replication safe. Due to http://bugs.mysql.com/bug.php?id=6980, subqueries cannot + // not replication safe. Due to https://bugs.mysql.com/bug.php?id=6980, subqueries cannot // be used here with MySQL. do { if ( $tinyQueue ) { // queue has <= MAX_OFFSET rows @@ -397,7 +398,7 @@ class JobQueueDB extends JobQueue { $row = false; // the row acquired do { if ( $dbw->getType() === 'mysql' ) { - // Per http://bugs.mysql.com/bug.php?id=6980, we can't use subqueries on the + // Per https://bugs.mysql.com/bug.php?id=6980, we can't use subqueries on the // same table being changed in an UPDATE query in MySQL (gives Error: 1093). // Oracle and Postgre have no such limitation. However, MySQL offers an // alternative here by supporting ORDER BY + LIMIT for UPDATE queries. @@ -565,7 +566,7 @@ class JobQueueDB extends JobQueue { * @return Iterator */ protected function getJobIterator( array $conds ) { - $dbr = $this->getSlaveDB(); + $dbr = $this->getReplicaDB(); try { return new MappedIterator( $dbr->select( 'job', self::selectFields(), $conds ), @@ -593,7 +594,7 @@ class JobQueueDB extends JobQueue { } protected function doGetSiblingQueuesWithJobs( array $types ) { - $dbr = $this->getSlaveDB(); + $dbr = $this->getReplicaDB(); // @note: this does not check whether the jobs are claimed or not. // This is useful so JobQueueGroup::pop() also sees queues that only // have stale jobs. This lets recycleAndDeleteStaleJobs() re-enqueue @@ -610,7 +611,7 @@ class JobQueueDB extends JobQueue { } protected function doGetSiblingQueueSizes( array $types ) { - $dbr = $this->getSlaveDB(); + $dbr = $this->getReplicaDB(); $res = $dbr->select( 'job', [ 'job_cmd', 'COUNT(*) AS count' ], [ 'job_cmd' => $types ], __METHOD__, [ 'GROUP BY' => 'job_cmd' ] ); @@ -736,7 +737,7 @@ class JobQueueDB extends JobQueue { * @throws JobQueueConnectionError * @return DBConnRef */ - protected function getSlaveDB() { + protected function getReplicaDB() { try { return $this->getDB( DB_REPLICA ); } catch ( DBConnectionError $e ) {