Symptoms
- Mail service cannot be activated on example.com. One of the following errors is displayed:
mailmng-outgoing failed: ERROR:__main__:UNIQUE constraint failed: vhost_ids.guid
mailmng-outgoing failed: ERROR:__main__:NOT NULL constraint failed: vhost_ids.domain_id
Cause
An orphaned entry with the guid of example.com already exists in the vhost_ids table of the outgoing mail limits /var/lib/plesk/mail/outgoing/data.db
database.
Resolution
One domain is affected
-
Connect to the server via SSH
- Enable debug.
- Reproduce the error.
- Find the following entry in /var/log/plesk/panel.log:
#7 /opt/psa/admin/plib/Mail/AbstractFacade.php(1670): Service_Driver_Mail_Plesk_Domain_Unix->addVhostId(string 'example.com', string '22ddab34-a039-4ef1-9f4c-cbeba73463fb')
- Disable debug.
- Backup the outgoing mail database:
# cp /var/lib/plesk/mail/outgoing/data.db{,.bkp}
- Open the outgoing mail database:
# sqlite3 /var/lib/plesk/mail/outgoing/data.db
- Check if the entry with guid from step 4 is in there:
# sqlite> select * from vhost_ids where guid="22ddab34-a039-4ef1-9f4c-cbeba73463fb";
22ddab34-a039-4ef1-9f4c-cbeba73463fb|49 - Check if it is orphaned(no domains with such id's in the domains table):
# sqlite> select * from domains where id=49
- Resolve the inconsistency:
- If the output in step 9 was empty, remove the orphaned entry from the vhosts_ids table:
# sqlite> delete from vhost_ids where guid="22ddab34-a039-4ef1-9f4c-cbeba73463fb";
- If the output in step 9 was not empty, apply the below solution from the "Multiple domains are affected" section.
- If the output in step 9 was empty, remove the orphaned entry from the vhosts_ids table:
Multiple domains are affected
- Connect to the server via SSH
- Backup the outgoing mail control database:
# cp /var/lib/plesk/mail/outgoing/data.db{,.bkp}
- Wipe the outgoing mail control database:
# plesk sbin mailmng-outgoing --destroy
- Recreate it:
# plesk sbin mailmng-outgoing --init