To reproduce:
- Add sleep(15) in PhabricatorMetaMTAMail->save() before $this->saveTransaction().
- Run bin/phd debug task in two windows.
- Take an action which sends mail (like commenting on a task).
Expect:
- Mail sent 15 seconds later.
Actual:
- MetaMTA worker is picked up immediately and fails to load the mail row.
2017-06-14 9:55:49 PM [STDE] [2017-06-14 21:55:49] EXCEPTION: (PhutilProxyException) Task "2171049" encountered a permanent failure and was cancelled. {>} (PhabricatorWorkerPermanentFailureException) Unable to load mail message (with ID "82852") while preparing to deliver it. at [<phabricator>/src/applications/metamta/PhabricatorMetaMTAWorker.php:35]
My understanding of how transaction isolation levels work is either missing some pieces, or there's some sort of other bug here.