[Rt-commit] rt branch, 4.2/purge-deferredrecipients, created. rt-4.2.10-98-gce1b9b0

Alex Vandiver alexmv at bestpractical.com
Wed Mar 4 16:50:18 EST 2015


The branch, 4.2/purge-deferredrecipients has been created
        at  ce1b9b0c473adf9aea4434a009ccf7859f3798fd (commit)

- Log -----------------------------------------------------------------
commit 370de4adcba36fe1ce4f7101f9de20c5defbe253
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Jun 23 12:32:12 2014 -0400

    Remove possibly large number of DeferredRecipients attributes
    
    RT 3.8.0 and 3.8.1 contained a bug, fixed in 9076df8b, which caused RT
    to create a NULL DeferredRecipients Attribute for every outgoing email.
    This not only bloats the database, but also causes problems with the RT
    3.8.2 "content" upgrade step:
    
            my $attrs = RT::Attributes->new( RT->SystemUser );
            $attrs->UnLimit;
            my @dashboards = $attrs->Named('Dashboard');
    
    This loads all Attribute records into memory, as Named does not perform
    a Limit, but builds a hash of all results, and iterates over them.
    
    Purge the NULL DeferredRecipients records, reducing database size and
    preventing the difficulties that it causes with the above upgrade step.
    This is done in both a 3.8.2 and 4.2.10 step -- the latter to reduce
    database bloat for users who have already upgraded past 3.8.2 but ran on
    3.8.0 or 3.8.1 for some time.
    
    Fixes I#17357.

diff --git a/etc/upgrade/3.8.2/content b/etc/upgrade/3.8.2/content
index 572e343..0a710df 100644
--- a/etc/upgrade/3.8.2/content
+++ b/etc/upgrade/3.8.2/content
@@ -3,6 +3,16 @@ use warnings;
 
 our @Initial = (
     sub {
+        # We do the delete in pure SQL because Attribute collections
+        # otherwise attempt to hash everything in memory.  As this may
+        # be a large list, do it directly.
+        RT->DatabaseHandle->dbh->do(<<EOSQL);
+            DELETE FROM Attributes
+             WHERE Name = 'DeferredRecipients'
+               AND Content IS NULL;
+EOSQL
+    },
+    sub {
         RT->Logger->warning(
             "Going to add [OLD] prefix to all templates in approvals queue."
             ." If you have never used approvals, you can safely delete all the"
diff --git a/etc/upgrade/4.2.11/content b/etc/upgrade/4.2.11/content
new file mode 100644
index 0000000..5118aff
--- /dev/null
+++ b/etc/upgrade/4.2.11/content
@@ -0,0 +1,15 @@
+use strict;
+use warnings;
+
+our @Initial = (
+    sub {
+        # We do the delete in pure SQL because Attribute collections
+        # otherwise attempt to hash everything in memory.  As this may
+        # be a large list, do it directly.
+        RT->DatabaseHandle->dbh->do(<<EOSQL);
+            DELETE FROM Attributes
+             WHERE Name = 'DeferredRecipients'
+               AND Content IS NULL;
+EOSQL
+    },
+);

commit ce1b9b0c473adf9aea4434a009ccf7859f3798fd
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Jun 23 12:48:12 2014 -0400

    Limit the collection to attributes with the correct Name
    
    There is no reason to not perform this restriction with a Limit; this
    query is even indexed, which may be a sizable performance benefit to
    sites with legitimately large Attributes tables.

diff --git a/etc/upgrade/3.8.2/content b/etc/upgrade/3.8.2/content
index 0a710df..dc68c92 100644
--- a/etc/upgrade/3.8.2/content
+++ b/etc/upgrade/3.8.2/content
@@ -138,7 +138,7 @@ our @Final = (
         my $sys = RT::System->new(RT->SystemUser);
 
         my $attrs = RT::Attributes->new( RT->SystemUser );
-        $attrs->UnLimit;
+        $attrs->Limit( FIELD => "Name", VALUE => "Dashboard");
         my @dashboards = $attrs->Named('Dashboard');
 
         if (@dashboards == 0) {

-----------------------------------------------------------------------


More information about the rt-commit mailing list