jenkins-bot has submitted this change and it was merged.
Change subject: Made JobRunner bail more smoothly on near OOM
......................................................................
Made JobRunner bail more smoothly on near OOM
* Use the regular limit-X style response instead of throwing an
exception. This avoids loss of statd data and the like.
Change-Id: Ia08384a0d13c268f6e7a673b2265ab77772e5539
---
M includes/jobqueue/JobRunner.php
1 file changed, 13 insertions(+), 4 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php
index 3982134..2465e5a 100644
--- a/includes/jobqueue/JobRunner.php
+++ b/includes/jobqueue/JobRunner.php
@@ -263,7 +263,10 @@
}
// Bail if near-OOM instead of in a job
- $this->assertMemoryOK();
+ if ( !$this->checkMemoryOK() ) {
+ $response['reached'] = 'memory-limit';
+ break;
+ }
}
} while ( $job ); // stop when there are no jobs
@@ -392,9 +395,9 @@
/**
* Make sure that this script is not too close to the memory usage
limit.
* It is better to die in between jobs than OOM right in the middle of
one.
- * @throws MWException
+ * @return bool
*/
- private function assertMemoryOK() {
+ private function checkMemoryOK() {
static $maxBytes = null;
if ( $maxBytes === null ) {
$m = array();
@@ -408,8 +411,14 @@
}
$usedBytes = memory_get_usage();
if ( $maxBytes && $usedBytes >= 0.95 * $maxBytes ) {
- throw new MWException( "Detected excessive memory usage
($usedBytes/$maxBytes)." );
+ $msg = "Detected excessive memory usage
($usedBytes/$maxBytes).";
+ $this->debugCallback( $msg );
+ $this->logger->error( $msg );
+
+ return false;
}
+
+ return true;
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/230236
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia08384a0d13c268f6e7a673b2265ab77772e5539
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits