1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

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
This commit is contained in:
Bob Trahan 2015-06-24 11:44:49 -07:00
parent fcb35a55fd
commit 189fb2660a
2 changed files with 21 additions and 8 deletions

View file

@ -6,16 +6,15 @@ final class MetaMTAMailSentGarbageCollector
public function collectGarbage() { public function collectGarbage() {
$ttl = phutil_units('90 days in seconds'); $ttl = phutil_units('90 days in seconds');
$table = new PhabricatorMetaMTAMail(); $mails = id(new PhabricatorMetaMTAMail())->loadAllWhere(
$conn_w = $table->establishConnection('w'); 'dateCreated < %d LIMIT 100',
PhabricatorTime::getNow());
queryfx( foreach ($mails as $mail) {
$conn_w, $mail->delete();
'DELETE FROM %T WHERE dateCreated < %d LIMIT 100', }
$table->getTableName(),
time() - $ttl);
return ($conn_w->getAffectedRows() == 100); return (count($mails) == 100);
} }
} }

View file

@ -1038,6 +1038,20 @@ final class PhabricatorMetaMTAMail
} }
} }
public function delete() {
$this->openTransaction();
queryfx(
$this->establishConnection('w'),
'DELETE FROM %T WHERE src = %s AND type = %d',
PhabricatorEdgeConfig::TABLE_NAME_EDGE,
$this->getPHID(),
PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST);
$ret = parent::delete();
$this->saveTransaction();
return $ret;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */ /* -( PhabricatorPolicyInterface )----------------------------------------- */