@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

MetaMTA - make sure mail garbage collection also cleans up recipient edges

Summary: Ref T5791. This edge table grows 2+X faster than the corresponding mail table depending on usage. Ergo, lets make sure to clean that up too in the delete code.

Test Plan: careful thought

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5791

Differential Revision: https://secure.phabricator.com/D13408

+21 -8
+7 -8
src/applications/metamta/garbagecollector/MetaMTAMailSentGarbageCollector.php
··· 6 6 public function collectGarbage() { 7 7 $ttl = phutil_units('90 days in seconds'); 8 8 9 - $table = new PhabricatorMetaMTAMail(); 10 - $conn_w = $table->establishConnection('w'); 9 + $mails = id(new PhabricatorMetaMTAMail())->loadAllWhere( 10 + 'dateCreated < %d LIMIT 100', 11 + PhabricatorTime::getNow()); 11 12 12 - queryfx( 13 - $conn_w, 14 - 'DELETE FROM %T WHERE dateCreated < %d LIMIT 100', 15 - $table->getTableName(), 16 - time() - $ttl); 13 + foreach ($mails as $mail) { 14 + $mail->delete(); 15 + } 17 16 18 - return ($conn_w->getAffectedRows() == 100); 17 + return (count($mails) == 100); 19 18 } 20 19 21 20 }
+14
src/applications/metamta/storage/PhabricatorMetaMTAMail.php
··· 1038 1038 } 1039 1039 } 1040 1040 1041 + public function delete() { 1042 + $this->openTransaction(); 1043 + queryfx( 1044 + $this->establishConnection('w'), 1045 + 'DELETE FROM %T WHERE src = %s AND type = %d', 1046 + PhabricatorEdgeConfig::TABLE_NAME_EDGE, 1047 + $this->getPHID(), 1048 + PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST); 1049 + $ret = parent::delete(); 1050 + $this->saveTransaction(); 1051 + 1052 + return $ret; 1053 + } 1054 + 1041 1055 1042 1056 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 1043 1057