1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-21 09:48:47 +02:00
phorge-phorge/src/applications/metamta
epriestley 3d70db9eb5 Queue a worker task to send mail only after committing the mail transaction
Summary:
Fixes T12844. This code is misleading: the daemon insert is happening on a different connection, and is not inside the transaction on the Mail connection.

What actually happens is this:

  - (Connection A) `BEGIN`
  - (Connection A) `INSERT INTO mail ...`
  - (Connection B) `INSERT INTO worker ...` <-- This is a different connection, and it is NOT in a transaction!
  - There's a race window here: the worker row is globally visible but the mail row is still isolated inside the transaction.
  - (Connection A) `COMMIT`
  - Now we're clear: the mail row is globally visible.

Change this code to reflect what's actually happening.

This means that if the worker row insert fails for some reason, we'll now throw with a mail row written to the database. But this is fine: it doesn't send on its own (so it can't cause mail loops or anything) and it can be re-queued with `bin/mail resend` if necessary without too much trouble.

Test Plan: See T12844 for particulars. Made some comments on tasks, saw the daemons send mail.

Reviewers: chad, amckinley, jmeador

Reviewed By: jmeador

Maniphest Tasks: T12844

Differential Revision: https://secure.phabricator.com/D18124
2017-06-14 12:27:00 -07:00
..
action When we fail to process mail, tell the user about it 2014-04-03 18:43:18 -07:00
adapter Explicitly quote "From" name part when submitting mail to the Mailgun API 2017-05-04 17:03:26 -07:00
application Move FontIcon calls to Icon 2016-01-28 08:48:45 -08:00
applicationpanel Separate button CSS classes 2017-06-05 20:14:34 +00:00
command Use PhutilClassMapQuery 2015-07-07 22:51:57 +10:00
constants Add basic support for Herald outbound rules 2015-08-15 10:54:33 -07:00
contentsource Modularize content sources 2016-03-26 11:59:45 -07:00
controller Convert all remaining old tabs to new PHUITabGroupViews 2016-06-30 18:50:09 -07:00
edge MetaMTA - more progress towards a mail application 2015-06-23 11:37:14 -07:00
editor Use ApplicationTransactions in ApplicationEmail 2015-06-11 10:15:49 -07:00
exception Apply some autofix linter rules 2014-09-10 06:55:05 +10:00
garbagecollector Provide bin/garbage for interacting with garbage collection 2015-10-02 09:17:24 -07:00
herald Make Herald test workflow modular and more clear 2016-08-03 16:12:33 -07:00
management Raise a tailored error message on "show-outbound --id cat" 2017-04-18 09:51:26 -07:00
parser Extend from Phobject 2015-06-15 18:02:27 +10:00
phid Mark PhabricatorPHIDType::getPHIDTypeApplicationClass() as abstract 2015-11-03 06:47:12 +11:00
query Reduce application search engine results list for Dashboards 2017-02-22 12:42:43 -08:00
receiver Rename "PhabricatorHash::digest()" to "weakDigest()" 2017-04-06 15:43:33 -07:00
replyhandler Make caches misses throw by default intead of inline-generating 2016-06-05 08:51:54 -07:00
storage Queue a worker task to send mail only after committing the mail transaction 2017-06-14 12:27:00 -07:00
typeahead Make packages mailable and subscribable 2016-05-13 17:18:57 -07:00
view Highlight inline diff context in HTML mail 2016-05-05 11:13:27 -07:00
PhabricatorMetaMTAWorker.php Send permanent dameon failures to the log, even when not running in verbose mode 2017-06-08 15:26:19 -07:00