Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15381103
D8115.id18380.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D8115.id18380.diff
View Options
Index: resources/sql/autopatches/20140130.mail.1.retry.sql
===================================================================
--- /dev/null
+++ resources/sql/autopatches/20140130.mail.1.retry.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_metamta.metamta_mail
+ DROP COLUMN retryCount;
Index: resources/sql/autopatches/20140130.mail.2.next.sql
===================================================================
--- /dev/null
+++ resources/sql/autopatches/20140130.mail.2.next.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_metamta.metamta_mail
+ DROP COLUMN nextRetry;
Index: src/applications/metamta/PhabricatorMetaMTAWorker.php
===================================================================
--- src/applications/metamta/PhabricatorMetaMTAWorker.php
+++ src/applications/metamta/PhabricatorMetaMTAWorker.php
@@ -3,42 +3,39 @@
final class PhabricatorMetaMTAWorker
extends PhabricatorWorker {
- private $message;
+ public function getMaximumRetryCount() {
+ return 250;
+ }
public function getWaitBeforeRetry(PhabricatorWorkerTask $task) {
- $message = $this->loadMessage();
- if (!$message) {
- return null;
- }
-
- $wait = max($message->getNextRetry() - time(), 0) + 15;
- return $wait;
+ return ($task->getFailureCount() * 15);
}
public function doWork() {
$message = $this->loadMessage();
- if (!$message
- || $message->getStatus() != PhabricatorMetaMTAMail::STATUS_QUEUE) {
+ if (!$message) {
+ throw new PhabricatorWorkerPermanentFailureException(
+ pht('Unable to load message!'));
+ }
+
+ if ($message->getStatus() != PhabricatorMetaMTAMail::STATUS_QUEUE) {
return;
}
+
$id = $message->getID();
$message->sendNow();
+
// task failed if the message is still queued
// (instead of sent, void, or failed)
if ($message->getStatus() == PhabricatorMetaMTAMail::STATUS_QUEUE) {
- throw new Exception('Failed to send message');
+ throw new Exception(
+ pht('Failed to send message.'));
}
}
private function loadMessage() {
- if (!$this->message) {
- $message_id = $this->getTaskData();
- $this->message = id(new PhabricatorMetaMTAMail())->load($message_id);
- if (!$this->message) {
- return null;
- }
- }
- return $this->message;
+ $message_id = $this->getTaskData();
+ return id(new PhabricatorMetaMTAMail())->load($message_id);
}
public function renderForDisplay(PhabricatorUser $viewer) {
Index: src/applications/metamta/management/PhabricatorMailManagementResendWorkflow.php
===================================================================
--- src/applications/metamta/management/PhabricatorMailManagementResendWorkflow.php
+++ src/applications/metamta/management/PhabricatorMailManagementResendWorkflow.php
@@ -54,9 +54,6 @@
}
$message->setStatus(PhabricatorMetaMTAMail::STATUS_QUEUE);
- $message->setRetryCount(0);
- $message->setNextRetry(time());
-
$message->save();
$mailer_task = PhabricatorWorker::scheduleTask(
Index: src/applications/metamta/management/PhabricatorMailManagementShowOutboundWorkflow.php
===================================================================
--- src/applications/metamta/management/PhabricatorMailManagementShowOutboundWorkflow.php
+++ src/applications/metamta/management/PhabricatorMailManagementShowOutboundWorkflow.php
@@ -50,8 +50,6 @@
$info[] = pht('PROPERTIES');
$info[] = pht('ID: %d', $message->getID());
$info[] = pht('Status: %s', $message->getStatus());
- $info[] = pht('Retry Count: %s', $message->getRetryCount());
- $info[] = pht('Next Retry: %s', $message->getNextRetry());
$info[] = pht('Related PHID: %s', $message->getRelatedPHID());
$info[] = pht('Message: %s', $message->getMessage());
Index: src/applications/metamta/storage/PhabricatorMetaMTAMail.php
===================================================================
--- src/applications/metamta/storage/PhabricatorMetaMTAMail.php
+++ src/applications/metamta/storage/PhabricatorMetaMTAMail.php
@@ -1,8 +1,6 @@
<?php
/**
- * See #394445 for an explanation of why this thing even exists.
- *
* @task recipients Managing Recipients
*/
final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO {
@@ -12,14 +10,11 @@
const STATUS_FAIL = 'fail';
const STATUS_VOID = 'void';
- const MAX_RETRIES = 250;
const RETRY_DELAY = 5;
protected $parameters;
protected $status;
protected $message;
- protected $retryCount;
- protected $nextRetry;
protected $relatedPHID;
private $excludePHIDs = array();
@@ -28,8 +23,6 @@
public function __construct() {
$this->status = self::STATUS_QUEUE;
- $this->retryCount = 0;
- $this->nextRetry = time();
$this->parameters = array();
parent::__construct();
@@ -228,15 +221,6 @@
return $this;
}
- public function getSimulatedFailureCount() {
- return nonempty($this->getParam('simulated-failures'), 0);
- }
-
- public function setSimulatedFailureCount($count) {
- $this->setParam('simulated-failures', $count);
- return $this;
- }
-
public function getWorkerTaskID() {
return $this->getParam('worker-task');
}
@@ -339,10 +323,6 @@
if ($this->getStatus() != self::STATUS_QUEUE) {
throw new Exception("Trying to send an already-sent mail!");
}
-
- if (time() < $this->getNextRetry()) {
- throw new Exception("Trying to send an email before next retry!");
- }
}
try {
@@ -611,32 +591,20 @@
return $this->save();
}
- if ($this->getRetryCount() < $this->getSimulatedFailureCount()) {
+ try {
+ $ok = $mailer->send();
+ $error = null;
+ } catch (PhabricatorMetaMTAPermanentFailureException $ex) {
+ $this->setStatus(self::STATUS_FAIL);
+ $this->setMessage($ex->getMessage());
+ return $this->save();
+ } catch (Exception $ex) {
$ok = false;
- $error = 'Simulated failure.';
- } else {
- try {
- $ok = $mailer->send();
- $error = null;
- } catch (PhabricatorMetaMTAPermanentFailureException $ex) {
- $this->setStatus(self::STATUS_FAIL);
- $this->setMessage($ex->getMessage());
- return $this->save();
- } catch (Exception $ex) {
- $ok = false;
- $error = $ex->getMessage()."\n".$ex->getTraceAsString();
- }
+ $error = $ex->getMessage()."\n".$ex->getTraceAsString();
}
if (!$ok) {
$this->setMessage($error);
- if ($this->getRetryCount() > self::MAX_RETRIES) {
- $this->setStatus(self::STATUS_FAIL);
- } else {
- $this->setRetryCount($this->getRetryCount() + 1);
- $next_retry = time() + ($this->getRetryCount() * self::RETRY_DELAY);
- $this->setNextRetry($next_retry);
- }
} else {
$this->setStatus(self::STATUS_SENT);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 15, 5:54 AM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7392409
Default Alt Text
D8115.id18380.diff (6 KB)
Attached To
Mode
D8115: Remove retry/failure mechanisms from MetaMTA
Attached
Detach File
Event Timeline
Log In to Comment