jenkins-bot has submitted this change and it was merged.
Change subject: Cleanups for runJobs.php.
......................................................................
Cleanups for runJobs.php.
* Handle exceptions in run() better.
* Made the profiling more accurate.
* Simplified the code to handle non-boolean results of run().
wfWarn() was removed, and bugs reports were already filed.
Change-Id: Ic702319420efbdf12c17d51494255a64a6212d99
---
M maintenance/runJobs.php
1 file changed, 16 insertions(+), 12 deletions(-)
Approvals:
Aaron Schulz: Looks good to me, approved
jenkins-bot: Verified
diff --git a/maintenance/runJobs.php b/maintenance/runJobs.php
index d582f51..f9557ce 100644
--- a/maintenance/runJobs.php
+++ b/maintenance/runJobs.php
@@ -87,33 +87,37 @@
? $group->pop( JobQueueGroup::TYPE_DEFAULT,
JobQueueGroup::USE_CACHE )
: $group->pop( $type ); // job from a single
queue
if ( $job ) { // found a job
- // Perform the job (logging success/failure and
runtime)...
- $t = microtime( true );
$this->runJobsLog( $job->toString() . "
STARTING" );
- $status = $job->run();
- if ( !is_bool( $status ) ) {
- wfWarn( $job->getType() . " job failed
to return a boolean." );
- $status = true; // sanity
+ // Run the job...
+ $t = microtime( true );
+ try {
+ $status = $job->run();
+ $error = $job->getLastError();
+ } catch ( MWException $e ) {
+ $status = false;
+ $error = get_class( $e ) . ': ' .
$e->getMessage();
}
- if ( $status || !$job->allowRetries() ) {
+ $timeMs = intval( ( microtime( true ) - $t ) *
1000 );
+
+ // Mark the job as done on success or when the
job cannot be retried
+ if ( $status !== false || !$job->allowRetries()
) {
$group->ack( $job ); // done
}
- $t = microtime( true ) - $t;
- $timeMs = intval( $t * 1000 );
if ( !$status ) {
- $this->runJobsLog( $job->toString() . "
t=$timeMs error={$job->error}" );
+ $this->runJobsLog( $job->toString() . "
t=$timeMs error={$error}" );
} else {
$this->runJobsLog( $job->toString() . "
t=$timeMs good" );
}
+
// Break out if we hit the job count or wall
time limits...
if ( $maxJobs && ++$n >= $maxJobs ) {
break;
- }
- if ( $maxTime && ( time() - $startTime ) >
$maxTime ) {
+ } elseif ( $maxTime && ( time() - $startTime )
> $maxTime ) {
break;
}
+
// Don't let any slaves/backups fall behind...
$group->get( $job->getType()
)->waitForBackups();
}
--
To view, visit https://gerrit.wikimedia.org/r/50033
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic702319420efbdf12c17d51494255a64a6212d99
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits