summaryrefslogtreecommitdiffstats
path: root/Bugzilla/JobQueue.pm
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2014-06-11 16:47:34 +0200
committerByron Jones <glob@mozilla.com>2014-06-11 16:47:34 +0200
commit4d5e362475a95c83f478b846ed847ac5ebe31234 (patch)
treeead03fed8c931c4f68d4252f6e6b1c5ded12c9cd /Bugzilla/JobQueue.pm
parent617eeba567adb04ca54b89906cde5676728dac51 (diff)
downloadbugzilla-4d5e362475a95c83f478b846ed847ac5ebe31234.tar.gz
bugzilla-4d5e362475a95c83f478b846ed847ac5ebe31234.tar.xz
Bug 962424: jobqueue's worker process should process messages in batches
r=?,a=?
Diffstat (limited to 'Bugzilla/JobQueue.pm')
-rw-r--r--Bugzilla/JobQueue.pm14
1 files changed, 14 insertions, 0 deletions
diff --git a/Bugzilla/JobQueue.pm b/Bugzilla/JobQueue.pm
index d67066322..4ff5750da 100644
--- a/Bugzilla/JobQueue.pm
+++ b/Bugzilla/JobQueue.pm
@@ -30,6 +30,10 @@ use constant JOB_MAP => {
# across requests.
use constant DRIVER_CACHE_TIME => 300; # 5 minutes
+# To avoid memory leak/fragmentation, a worker process won't process more than
+# MAX_MESSAGES messages.
+use constant MAX_MESSAGES => 1000;
+
sub job_map {
if (!defined(Bugzilla->request_cache->{job_map})) {
my $job_map = JOB_MAP;
@@ -155,6 +159,16 @@ sub work_once {
return $self->SUPER::work_once(@_);
}
+# Never process more than MAX_MESSAGES in one batch, to avoid memory
+# leak/fragmentation issues.
+sub work_until_done {
+ my $self = shift;
+ my $count = 0;
+ while ($count++ < MAX_MESSAGES) {
+ $self->work_once or last;
+ }
+}
+
1;
__END__