From c2e2a56414f46debb2d45bfc9f9936bfb3de3c3d Mon Sep 17 00:00:00 2001 From: "bzrmirror%bugzilla.org" Date: Wed, 11 Jun 2014 15:00:51 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20962424:=20jobqueue's=20worker=20process?= =?UTF-8?q?=20should=20process=20messages=20in=20batches=20r=3D=3F,a=3D=3F?= git-svn-id: svn://10.0.0.236/trunk@265424 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/.bzrrev | 2 +- mozilla/webtools/bugzilla/.gitrev | 2 +- mozilla/webtools/bugzilla/Bugzilla/JobQueue.pm | 14 ++++++++++++++ mozilla/webtools/bugzilla/jobqueue.pl | 2 +- mozilla/webtools/bugzilla/t/011pod.t | 2 +- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/mozilla/webtools/bugzilla/.bzrrev b/mozilla/webtools/bugzilla/.bzrrev index 1a3eba00e39..f5fa890da83 100644 --- a/mozilla/webtools/bugzilla/.bzrrev +++ b/mozilla/webtools/bugzilla/.bzrrev @@ -1 +1 @@ -9050 \ No newline at end of file +9051 \ No newline at end of file diff --git a/mozilla/webtools/bugzilla/.gitrev b/mozilla/webtools/bugzilla/.gitrev index 7046f6ec91c..df1408425ac 100644 --- a/mozilla/webtools/bugzilla/.gitrev +++ b/mozilla/webtools/bugzilla/.gitrev @@ -1 +1 @@ -617eeba567adb04ca54b89906cde5676728dac51 \ No newline at end of file +4d5e362475a95c83f478b846ed847ac5ebe31234 \ No newline at end of file diff --git a/mozilla/webtools/bugzilla/Bugzilla/JobQueue.pm b/mozilla/webtools/bugzilla/Bugzilla/JobQueue.pm index d6706632249..4ff5750da80 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/JobQueue.pm +++ b/mozilla/webtools/bugzilla/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/mozilla/webtools/bugzilla/jobqueue.pl b/mozilla/webtools/bugzilla/jobqueue.pl index c8afd74cc45..d538e478469 100755 --- a/mozilla/webtools/bugzilla/jobqueue.pl +++ b/mozilla/webtools/bugzilla/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/mozilla/webtools/bugzilla/t/011pod.t b/mozilla/webtools/bugzilla/t/011pod.t index 37cd2da37ec..c3ec39898de 100644 --- a/mozilla/webtools/bugzilla/t/011pod.t +++ b/mozilla/webtools/bugzilla/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$/, );