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() {
$ttl = phutil_units('90 days in seconds');
$table = new PhabricatorMetaMTAMail();
$conn_w = $table->establishConnection('w');
$mails = id(new PhabricatorMetaMTAMail())->loadAllWhere(
'dateCreated < %d LIMIT 100',
PhabricatorTime::getNow());
queryfx(
$conn_w,
'DELETE FROM %T WHERE dateCreated < %d LIMIT 100',
$table->getTableName(),
time() - $ttl);
foreach ($mails as $mail) {
$mail->delete();
}
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 )----------------------------------------- */