Jump to content

Phabricator/Mail debugging

From Wikitech

For end-user management of mail, see mw:Phabricator/Help/Managing mail.

This a dump of rough notes on debugging notification mail on the Phabricator/Phorge instance. They may or may not be useful or correct.

Gathered while investigating phab:T370352 about missing notifications, which turned out to be a mail provider issue.

Command-line tools

sudo bin/mail offers some diagnostics on mail, can resend specific mails, and simulate sending mail. It feels fairly limited, but is probably a good first stop.

Database mail info

At the database level, mail info seems to be stored mostly in phabricator_metamta, and especially the table phabricator_metamta.metamta_mail.

describe metamta_mail;
Current database: phabricator_metamta
+--------------+------------------+------+-----+---------+----------------+
| Field        | Type             | Null | Key | Default | Extra          |
+--------------+------------------+------+-----+---------+----------------+
| id           | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| phid         | varbinary(64)    | NO   | UNI | NULL    |                |
| actorPHID    | varbinary(64)    | YES  | MUL | NULL    |                |
| parameters   | longtext         | NO   |     | NULL    |                |
| status       | varchar(32)      | NO   | MUL | NULL    |                |
| message      | longtext         | YES  |     | NULL    |                |
| relatedPHID  | varbinary(64)    | YES  | MUL | NULL    |                |
| dateCreated  | int(10) unsigned | NO   | MUL | NULL    |                |
| dateModified | int(10) unsigned | NO   |     | NULL    |                |
+--------------+------------------+------+-----+---------+----------------+

Of particular interest here are actorPHID, relatedPHID, and parameters.

Pretty much every entity in the database has a PHID. If looking for the mail related to a task, one can use a task PHID like so:

select count(*) from metamta_mail where relatedPHID = 'PHID-TASK-2iacqyb64oiku3uw35ct';

To retrieve the PHID for a task, you can use the conduit lookup here:

https://phabricator.wikimedia.org/conduit/method/maniphest.info/

parameters is a JSON blob containing various values, including stamps, which contains a list of recipients.

MySQL supports extracting JSON values like so:

select json_extract(parameters, '$.stamps') as stamps from metamta_mail where relatedPHID = 'PHID-TASK-2iacqyb64oiku3uw35ct';

...but an easier approach may be to use a brute force LIKE:

select count(*) from metamta_mail where relatedPHID = 'PHID-TASK-2iacqyb64oiku3uw35ct' and parameters like '%@username%';