Bug 962424: jobqueue's worker process should process messages in batches

r=?,a=?


git-svn-id: svn://10.0.0.236/trunk@265424 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzrmirror%bugzilla.org 2014-06-11 15:00:51 +00:00
parent 5cd8be4bf2
commit c2e2a56414
5 changed files with 18 additions and 4 deletions

View File

@ -1 +1 @@
9050 9051

View File

@ -1 +1 @@
617eeba567adb04ca54b89906cde5676728dac51 4d5e362475a95c83f478b846ed847ac5ebe31234

View File

@ -30,6 +30,10 @@ use constant JOB_MAP => {
# across requests. # across requests.
use constant DRIVER_CACHE_TIME => 300; # 5 minutes 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 { sub job_map {
if (!defined(Bugzilla->request_cache->{job_map})) { if (!defined(Bugzilla->request_cache->{job_map})) {
my $job_map = JOB_MAP; my $job_map = JOB_MAP;
@ -155,6 +159,16 @@ sub work_once {
return $self->SUPER::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; 1;
__END__ __END__

View File

@ -45,7 +45,7 @@ jobqueue.pl - Runs jobs in the background for Bugzilla.
restart Stops a running jobqueue if one is running, and then restart Stops a running jobqueue if one is running, and then
starts a new one. starts a new one.
once Checks the job queue once, executes the first item found (if 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 onepass Checks the job queue, executes all items found, and then exits
check Report the current status of the daemon. check Report the current status of the daemon.
install On some *nix systems, this automatically installs and install On some *nix systems, this automatically installs and

View File

@ -30,7 +30,7 @@ use constant DEFAULT_WHITELIST => qr/^(?:new|new_from_list|check|run_create_vali
use constant SUB_WHITELIST => ( use constant SUB_WHITELIST => (
'Bugzilla::Flag' => qr/^(?:(force_)?retarget|force_cleanup)$/, 'Bugzilla::Flag' => qr/^(?:(force_)?retarget|force_cleanup)$/,
'Bugzilla::FlagType' => qr/^sqlify_criteria$/, '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$/, 'Bugzilla::Search' => qr/^SPECIAL_PARSING$/,
); );