summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-09-02 07:41:48 +0200
committerByron Jones <glob@mozilla.com>2015-09-02 07:41:48 +0200
commit0f2dd8d714a424cf383d925f8b55a098716b0660 (patch)
tree93f4c1304268eefd0ca169be1260be257309acd9
parent34e6b2e7cad19a2345328323fd81ac477e13e7eb (diff)
downloadbugzilla-0f2dd8d714a424cf383d925f8b55a098716b0660.tar.gz
bugzilla-0f2dd8d714a424cf383d925f8b55a098716b0660.tar.xz
Bug 1199136 - lower memory consumption to better operate in bugzilladm's
low memory environment
-rw-r--r--Bugzilla/Object.pm32
-rwxr-xr-xscripts/update-bug-groups.pl9
2 files changed, 37 insertions, 4 deletions
diff --git a/Bugzilla/Object.pm b/Bugzilla/Object.pm
index 2349b57e6..84d384d2b 100644
--- a/Bugzilla/Object.pm
+++ b/Bugzilla/Object.pm
@@ -276,6 +276,16 @@ sub object_cache_key {
}
}
+sub object_cache_clearall {
+ my $class = shift;
+ my $cache = Bugzilla->request_cache;
+ $class = blessed($class) if blessed($class);
+ my $prefix = $class . ',';
+ foreach my $key (grep { substr($_, 0, length($prefix)) eq $prefix } keys %$cache) {
+ delete $cache->{$key};
+ }
+}
+
# To support serialisation, we need to capture the keys in an object's default
# hashref.
sub _serialisation_keys {
@@ -1526,6 +1536,28 @@ $bug->object_cache_set();
=back
+=item C<object_cache_clearall>
+
+=over
+
+=item B<Description>
+
+Removes all objects for the specified class from the cache.
+
+=item B<Params>
+
+(none)
+
+=item B<Returns>
+
+(nothing)
+
+=item B<Example>
+
+Bugzilla::User->object_cache_clearall();
+
+=back
+
=back
=head1 CLASS FUNCTIONS
diff --git a/scripts/update-bug-groups.pl b/scripts/update-bug-groups.pl
index cec3d4696..173269e7c 100755
--- a/scripts/update-bug-groups.pl
+++ b/scripts/update-bug-groups.pl
@@ -75,10 +75,9 @@ print "Query matched $count bug(s)\nPress <Ctrl-C> to stop or <Enter> to continu
getc();
my $dbh = Bugzilla->dbh;
-$dbh->bz_start_transaction;
-
my $updated = 0;
foreach my $ra (@$bugs) {
+ $dbh->bz_start_transaction;
my ($bug_id, $summary) = @$ra;
print "$bug_id - $summary\n";
my $bug = Bugzilla::Bug->check($bug_id);
@@ -89,8 +88,10 @@ foreach my $ra (@$bugs) {
$dbh->do("UPDATE bugs SET lastdiffed = delta_ts WHERE bug_id = ?", undef, $bug->id);
$updated++;
}
-}
+ $dbh->bz_commit_transaction;
-$dbh->bz_commit_transaction;
+ # drop cached user objects to avoid excessive memory usage
+ Bugzilla::User->object_cache_clearall();
+}
print "\nUpdated $updated bugs(s)\n";