dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Add support for PHP7 random_bytes in favor of mcrypt_create_iv"
[lhc/web/wiklou.git]
/
includes
/
jobqueue
/
JobRunner.php
diff --git
a/includes/jobqueue/JobRunner.php
b/includes/jobqueue/JobRunner.php
index
990f112
..
baff288
100644
(file)
--- a/
includes/jobqueue/JobRunner.php
+++ b/
includes/jobqueue/JobRunner.php
@@
-27,6
+27,7
@@
use Liuggio\StatsdClient\Factory\StatsdDataFactory;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use Wikimedia\ScopedCallback;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use Wikimedia\ScopedCallback;
+use Wikimedia\Rdbms\LBFactory;
/**
* Job queue runner utility methods
/**
* Job queue runner utility methods
@@
-46,6
+47,7
@@
class JobRunner implements LoggerAwareInterface {
const MAX_ALLOWED_LAG = 3; // abort if more than this much DB lag is present
const LAG_CHECK_PERIOD = 1.0; // check replica DB lag this many seconds
const ERROR_BACKOFF_TTL = 1; // seconds to back off a queue due to errors
const MAX_ALLOWED_LAG = 3; // abort if more than this much DB lag is present
const LAG_CHECK_PERIOD = 1.0; // check replica DB lag this many seconds
const ERROR_BACKOFF_TTL = 1; // seconds to back off a queue due to errors
+ const READONLY_BACKOFF_TTL = 30; // seconds to back off a queue due to read-only errors
/**
* @param callable $debug Optional debug output handler
/**
* @param callable $debug Optional debug output handler
@@
-190,7
+192,7
@@
class JobRunner implements LoggerAwareInterface {
// Back off of certain jobs for a while (for throttling and for errors)
if ( $info['status'] === false && mt_rand( 0, 49 ) == 0 ) {
// Back off of certain jobs for a while (for throttling and for errors)
if ( $info['status'] === false && mt_rand( 0, 49 ) == 0 ) {
- $ttw = max( $ttw,
self::ERROR_BACKOFF_TTL ); // too many errors
+ $ttw = max( $ttw,
$this->getErrorBackoffTTL( $info['error'] ) );
$backoffDeltas[$jType] = isset( $backoffDeltas[$jType] )
? $backoffDeltas[$jType] + $ttw
: $ttw;
$backoffDeltas[$jType] = isset( $backoffDeltas[$jType] )
? $backoffDeltas[$jType] + $ttw
: $ttw;
@@
-253,6
+255,16
@@
class JobRunner implements LoggerAwareInterface {
return $response;
}
return $response;
}
+ /**
+ * @param string $error
+ * @return int TTL in seconds
+ */
+ private function getErrorBackoffTTL( $error ) {
+ return strpos( $error, 'DBReadOnlyError' ) !== false
+ ? self::READONLY_BACKOFF_TTL
+ : self::ERROR_BACKOFF_TTL;
+ }
+
/**
* @param Job $job
* @param LBFactory $lbFactory
/**
* @param Job $job
* @param LBFactory $lbFactory