mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Add a GC for sent and received mail
Summary: Ref T4368. We don't currently GC these tables, and the sent mail table is one of the largest on `secure.phabricator.com`. There's no value in retaining this information indefinitely. Instead, retain it for 90 days, which should be plenty of time to debug/diagnose any issues. Test Plan: Ran `phd debug garbage`, saw it clean up a reasonable amount of data from these tables. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4368 Differential Revision: https://secure.phabricator.com/D8127
This commit is contained in:
parent
29b29c109d
commit
88436349b8
5 changed files with 50 additions and 0 deletions
2
resources/sql/autopatches/20140201.gc.1.mailsent.sql
Normal file
2
resources/sql/autopatches/20140201.gc.1.mailsent.sql
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_metamta.metamta_mail
|
||||||
|
ADD KEY `key_created` (dateCreated);
|
2
resources/sql/autopatches/20140201.gc.2.mailreceived.sql
Normal file
2
resources/sql/autopatches/20140201.gc.2.mailreceived.sql
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_metamta.metamta_receivedmail
|
||||||
|
ADD KEY `key_created` (dateCreated);
|
|
@ -923,6 +923,8 @@ phutil_register_library_map(array(
|
||||||
'ManiphestTransactionSaveController' => 'applications/maniphest/controller/ManiphestTransactionSaveController.php',
|
'ManiphestTransactionSaveController' => 'applications/maniphest/controller/ManiphestTransactionSaveController.php',
|
||||||
'ManiphestView' => 'applications/maniphest/view/ManiphestView.php',
|
'ManiphestView' => 'applications/maniphest/view/ManiphestView.php',
|
||||||
'MetaMTAConstants' => 'applications/metamta/constants/MetaMTAConstants.php',
|
'MetaMTAConstants' => 'applications/metamta/constants/MetaMTAConstants.php',
|
||||||
|
'MetaMTAMailReceivedGarbageCollector' => 'applications/metamta/garbagecollector/MetaMTAMailReceivedGarbageCollector.php',
|
||||||
|
'MetaMTAMailSentGarbageCollector' => 'applications/metamta/garbagecollector/MetaMTAMailSentGarbageCollector.php',
|
||||||
'MetaMTANotificationType' => 'applications/metamta/constants/MetaMTANotificationType.php',
|
'MetaMTANotificationType' => 'applications/metamta/constants/MetaMTANotificationType.php',
|
||||||
'MetaMTAReceivedMailStatus' => 'applications/metamta/constants/MetaMTAReceivedMailStatus.php',
|
'MetaMTAReceivedMailStatus' => 'applications/metamta/constants/MetaMTAReceivedMailStatus.php',
|
||||||
'NuanceCapabilitySourceDefaultEdit' => 'applications/nuance/capability/NuanceCapabilitySourceDefaultEdit.php',
|
'NuanceCapabilitySourceDefaultEdit' => 'applications/nuance/capability/NuanceCapabilitySourceDefaultEdit.php',
|
||||||
|
@ -3513,6 +3515,8 @@ phutil_register_library_map(array(
|
||||||
'ManiphestTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
'ManiphestTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||||
'ManiphestTransactionSaveController' => 'ManiphestController',
|
'ManiphestTransactionSaveController' => 'ManiphestController',
|
||||||
'ManiphestView' => 'AphrontView',
|
'ManiphestView' => 'AphrontView',
|
||||||
|
'MetaMTAMailReceivedGarbageCollector' => 'PhabricatorGarbageCollector',
|
||||||
|
'MetaMTAMailSentGarbageCollector' => 'PhabricatorGarbageCollector',
|
||||||
'MetaMTANotificationType' => 'MetaMTAConstants',
|
'MetaMTANotificationType' => 'MetaMTAConstants',
|
||||||
'MetaMTAReceivedMailStatus' => 'MetaMTAConstants',
|
'MetaMTAReceivedMailStatus' => 'MetaMTAConstants',
|
||||||
'NuanceCapabilitySourceDefaultEdit' => 'PhabricatorPolicyCapability',
|
'NuanceCapabilitySourceDefaultEdit' => 'PhabricatorPolicyCapability',
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class MetaMTAMailReceivedGarbageCollector
|
||||||
|
extends PhabricatorGarbageCollector {
|
||||||
|
|
||||||
|
public function collectGarbage() {
|
||||||
|
$ttl = phutil_units('90 days in seconds');
|
||||||
|
|
||||||
|
$table = new PhabricatorMetaMTAReceivedMail();
|
||||||
|
$conn_w = $table->establishConnection('w');
|
||||||
|
|
||||||
|
queryfx(
|
||||||
|
$conn_w,
|
||||||
|
'DELETE FROM %T WHERE dateCreated < %d LIMIT 100',
|
||||||
|
$table->getTableName(),
|
||||||
|
time() - $ttl);
|
||||||
|
|
||||||
|
return ($conn_w->getAffectedRows() == 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class MetaMTAMailSentGarbageCollector
|
||||||
|
extends PhabricatorGarbageCollector {
|
||||||
|
|
||||||
|
public function collectGarbage() {
|
||||||
|
$ttl = phutil_units('90 days in seconds');
|
||||||
|
|
||||||
|
$table = new PhabricatorMetaMTAMail();
|
||||||
|
$conn_w = $table->establishConnection('w');
|
||||||
|
|
||||||
|
queryfx(
|
||||||
|
$conn_w,
|
||||||
|
'DELETE FROM %T WHERE dateCreated < %d LIMIT 100',
|
||||||
|
$table->getTableName(),
|
||||||
|
time() - $ttl);
|
||||||
|
|
||||||
|
return ($conn_w->getAffectedRows() == 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue