summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla/JobQueue.pm14
-rwxr-xr-xjobqueue.pl2
-rw-r--r--t/011pod.t2
3 files changed, 16 insertions, 2 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__
diff --git a/jobqueue.pl b/jobqueue.pl
index c8afd74cc..d538e4784 100755
--- a/jobqueue.pl
+++ b/jobqueue.pl
@@ -45,7 +45,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
diff --git a/t/011pod.t b/t/011pod.t
index 37cd2da37..c3ec39898 100644
--- a/t/011pod.t
+++ b/t/011pod.t
@@ -30,7 +30,7 @@ use constant DEFAULT_WHITELIST => qr/^(?:new|new_from_list|check|run_create_vali
use constant SUB_WHITELIST => (
'Bugzilla::Flag' => qr/^(?:(force_)?retarget|force_cleanup)$/,
'Bugzilla::FlagType' => qr/^sqlify_criteria$/,
- 'Bugzilla::JobQueue' => qr/(?:^work_once|subprocess_worker)$/,
+ 'Bugzilla::JobQueue' => qr/(?:^work_once|work_until_done|subprocess_worker)$/,
'Bugzilla::Search' => qr/^SPECIAL_PARSING$/,
);