summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2014-06-11 17:00:52 +0200
committerByron Jones <glob@mozilla.com>2014-06-11 17:00:52 +0200
commit8690811cafbac9f588faac26044f6d428354f811 (patch)
treec8466abd9c12d0db63a91777aa96d721dfbec6e7
parent1a8d7747d93668b4189110712973515774de1c07 (diff)
downloadbugzilla-8690811cafbac9f588faac26044f6d428354f811.tar.gz
bugzilla-8690811cafbac9f588faac26044f6d428354f811.tar.xz
Bug 962424: jobqueue's worker process should process messages in batches
-rw-r--r--Bugzilla/JobQueue.pm14
-rwxr-xr-xjobqueue.pl2
2 files changed, 15 insertions, 1 deletions
diff --git a/Bugzilla/JobQueue.pm b/Bugzilla/JobQueue.pm
index a94598b87..669076dd5 100644
--- a/Bugzilla/JobQueue.pm
+++ b/Bugzilla/JobQueue.pm
@@ -43,6 +43,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;
@@ -160,6 +164,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__
diff --git a/jobqueue.pl b/jobqueue.pl
index 38ea97eb2..d7d6fd775 100755
--- a/jobqueue.pl
+++ b/jobqueue.pl
@@ -59,7 +59,7 @@ jobqueue.pl - Runs jobs in the background for Bugzilla.
restart Stops a running jobqueue if one is running, and then
starts a new one.
once Checks the job queue once, executes the first item found (if
- any) and then exits
+ any, up to a limit of 1000 items) and then exits
onepass Checks the job queue, executes all items found, and then exits
check Report the current status of the daemon.
install On some *nix systems, this automatically installs and